# Search Downloads

`GET https://api.torbox.app/v1/api/downloads/search`

- Operation ID: `search_downloads`
- Group: Downloads
- Auth: API key, `Authorization: Bearer <api key>` (Sign in with TorBox gives the same key)

### Overview

Searches the user's torrents, usenet downloads and web downloads by name and by file name, and returns the matches newest first. The items have the same fields and the same order as in Get Download List: each has `download_type` (`torrent`, `usenet` or `webdl`), and `files` defaults to false, so items leave out `files` and `expires_at` unless you send `files=true`. Nothing is cached, so results always show the current state of each download.

### How the query matches

- `query` is split into words on whitespace. Every word must appear, in any order, and case is ignored.

- A word matches any part of the text, as a plain substring. Dots, dashes and underscores are ordinary characters, not word breaks, and `%` and `_` match only themselves.

- An item matches when its name holds every word, or when the file name of one of its files holds every word.

- Only the file's own name is searched, not its folder. Downloads with many files that are stored as a single zip only have that zip's name, `{name}.zip`, to match.

- Hashes, links, paths and tags are not searched. Use `tag` to narrow by tag.

- `query` must have 1 to 200 characters after trimming spaces, and at most 10 different words. Otherwise, or when `query` is missing, the response is a 422 in FastAPI's validation error format (`{"detail": [...]}`), not the usual response.

### Filtering and paging

- `type` can be repeated, and keeps only those download types.

- `cached` keeps only cached (true) or uncached (false) items.

- `tag` can be repeated (`?tag=favorite&tag=important`), and keeps items with at least one of the tags, ignoring case.

- Filters combine with the query by AND. `offset` and `limit` then page through the matches, and a response holds at most `limit` items.

- A value of the wrong type, such as `type=webdownload` or `cached=maybe`, returns a 422 response in FastAPI's validation error format.

### Authorization

Requires an API key using the Authorization Bearer Header.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `offset` | query | integer | no | Determines how many matching items to skip. Default is 0. Optional. |
| `limit` | query | integer | no | Determines the number of items to receive per request. Default is 1000. Optional. |
| `files` | query | boolean | no | Include each item's `files` and `expires_at`. Default is false, so the results leave them out unless you set `files=true`. Optional. |
| `query` | query | string | yes | The words to find in the download's name or in one of its file names, ignoring case. Every word must appear. 1 to 200 characters and at most 10 words. Required. |
| `type` | query | string[] | no | Searches only these download types, `torrent`, `usenet` or `webdl`. Repeat it for several types. Optional. |
| `cached` | query | boolean | no | Shows only cached (true) or only uncached (false) downloads. Optional. |
| `tag` | query | string[] | no | Shows only downloads with at least one of these tags, ignoring case. Repeat it for several tags. Optional. |

## Responses

- `200` Successful Response
- `401` Unauthorized
- `403` Forbidden
- `404` Not Found
- `422` Validation Error
- `429` Too Many Requests
- `500` Internal Server Error
- `503` Service Unavailable
