getTorrents
SchemaSearch for torrents
search is either a free-text string or an options object. The accepted keys and
their permitted values are listed in the schema below.
Numeric filters accept a >, <, >= or <= prefix, e.g. {"age": ">=3600"}.
String fields accept SQL LIKE wildcards but apply none by default, so
{"series": "Simpsons"} matches nothing while {"series": "%Simpsons"} matches.
% is any number of characters, _ is exactly one; prefix either with \\ for a
literal.
Field names are case-insensitive, as are the choice-field values. A choice value matching nothing is silently dropped, so a typo widens the search rather than failing it.
results is clamped to 1000. torrents is omitted entirely when nothing matches,
rather than being present and empty.
Request
A JSON-RPC call is a POST of a single envelope object. There is no jsonrpc field, and id must be present and non-empty — an empty or absent id is treated as a notification and the server returns no body at all.
curl -sS -X POST https://api.broadcasthe.net/ \
-H 'Content-Type: application/json' \
-d '{"id":1,"method":"getTorrents","params":{"key":"YOUR_API_KEY","search":"<search>"}}'<?php
$body = json_encode([
'id' => 1,
'method' => 'getTorrents',
'params' => [
'key' => 'YOUR_API_KEY',
'search' => '<search>',
],
]);
$ch = curl_init("https://api.broadcasthe.net/");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
// Errors arrive as {"id":…, "result":null, "error":{…}} - result is present and null
// alongside error, so check for the error key rather than a falsy result.
if (isset($response['error'])) {
throw new RuntimeException($response['error']['message'], $response['error']['code']);
}
var_dump($response['result']);import requests
response = requests.post(
"https://api.broadcasthe.net/",
json={
"id": 1,
"method": "getTorrents",
"params": {
"key": "YOUR_API_KEY",
"search": "<search>",
},
},
timeout=30,
)
response.raise_for_status()
payload = response.json()
# result is present and null alongside error, so test for "error" itself.
if "error" in payload:
raise RuntimeError(f'{payload["error"]["code"]}: {payload["error"]["message"]}')
print(payload["result"])const response = await fetch("https://api.broadcasthe.net/", {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"id": 1,
"method": "getTorrents",
"params": {
"key": "YOUR_API_KEY",
"search": "<search>"
}
}),
})
const payload = await response.json()
// result is present and null alongside error, so test for the error key itself.
if (payload.error) {
throw new Error(`${payload.error.code}: ${payload.error.message}`)
}
console.log(payload.result)Try it
Requests run against the live site, and count against your quota.
Request
{ "id": 1, "method": "getTorrents", "params": {} }
Response
Not run yet.
Parameters
keystringrequiredAPI key
searchTorrentSearchOptions | [] | [TorrentSearchOptions] | stringrequiredTorrentSearchOptions | [] | [TorrentSearchOptions] | string
- eitherTorrentSearchOptions
idNumericCriterion (single or array)optionalA criterion on a numeric field. Send a bare integer for an exact match, or a string, which may carry a
>,>=,<or<=prefix to make the match a comparison rather than an equality, e.g.">=3600".group_idNumericCriterion (single or array)optionaltvdbNumericCriterion (single or array)optionaltvrageNumericCriterion (single or array)optionalimdbNumericCriterion (single or array)optionaltimeNumericCriterion (single or array)optionalsizeNumericCriterion (single or array)optionalageNumericCriterion (single or array)optionalhashstring (single or array)optionalseriesstringoptionalnamestringoptionalreleasestringoptionalsearchstringoptionaltagsstringoptionalrequire_all_tagsbooleanoptionalcategory"Season" | "Episode" (single or array)optionalcodec12 values (single or array)optional12 values
"XViD""x264""MPEG2""DiVX""DVDR""VC-1""H.264""WMV""BD""x264-Hi10P""H.265""VP9"
container10 values (single or array)optional10 values
"AVI""MKV""VOB""MPEG""MP4""ISO""WMV""TS""M4V""M2TS"
source21 values (single or array)optional21 values
"HDTV""PDTV""DSR""DVDRip""TVRip""VHSRip""Bluray""BDRip""BRRip""DVD5""DVD9""HDDVD""WEB""BD5""BD9""BD25""BD50""Mixed""WEBRip""WEB-DL""Unknown"
resolution7 values (single or array)optional7 values
"Portable Device""SD""720p""1080i""1080p""576p""2160p"
origin"None" | "Scene" | "P2P" | "User" | "Mixed" | "Internal" (single or array)optional
- or[]
- or[TorrentSearchOptions]
- orstring
resultsNumericInputoptionalA whole number, sent either as a JSON number or as a string containing one.
5and"5"are equivalent, and both are accepted wherever this type appears.offsetNumericInputoptional
Result
On success the response is {"id": …, "result": …}. The shape of result is:
resultsstring (numeric)requiredtorrentsmap<string, Torrent>optionalmap<string, Torrent>
An object keyed by ID — every value has the shape below.
GroupNamestringrequiredGroupIDstring (numeric)requiredTorrentIDstring (numeric)requiredSeriesIDstring (numeric)requiredSeriesstringrequiredSeriesBannerstring | nullrequiredSeriesPosterstring | nullrequiredYoutubeTrailerstring | nullrequiredCategory"Episode" | "Season"requiredSnatchedstring (numeric)requiredSeedersstring (numeric)requiredLeechersstring (numeric)requiredSourcestringrequiredContainerstringrequiredCodecstringrequiredResolutionstringrequiredOriginstringrequiredReleaseNamestringrequiredSizestring (numeric)requiredTimestring (numeric)requiredTvdbIDstring | nullrequiredTvrageIDstring | nullrequiredImdbIDstring | nullrequiredInfoHashstringrequiredTagsstring[]requiredGenresstring[]requiredDownloadURLstringrequired
Errors
On failure the response is {"id": …, "result": null, "error": {"code": …, "message": …}}. Note that result is present and null alongsideerror, so test for the error key rather than for a falsy result.
| Code | Message |
|---|---|
-32001 | Invalid API Key |
-32002 | Call Limit Exceeded |
-32003 | User Account Disabled |
-32004 | IP address needs authorization - please check your notices on BTN |
-32004 | Unauthorized IP address |
-32004 is the most likely failure on a first call: the API allowlists source IPs, and an unrecognised one is recorded for approval rather than accepted. See authorisation.