{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "method": "getTorrents",
    "group": "Torrents",
    "summary": "Search for torrents",
    "description": "`search` is either a free-text string or an options object. The accepted keys and\ntheir permitted values are listed in the schema below.\n\nNumeric filters accept a `>`, `<`, `>=` or `<=` prefix, e.g. `{\"age\": \">=3600\"}`.\n\nString fields accept SQL LIKE wildcards but apply none by default, so\n`{\"series\": \"Simpsons\"}` matches nothing while `{\"series\": \"%Simpsons\"}` matches.\n`%` is any number of characters, `_` is exactly one; prefix either with `\\\\` for a\nliteral.\n\nField names are case-insensitive, as are the choice-field values. A choice value\nmatching nothing is silently dropped, so a typo widens the search rather than\nfailing it.\n\n`results` is clamped to 1000. `torrents` is omitted entirely when nothing matches,\nrather than being present and empty.",
    "deprecated": false,
    "params": {
        "type": "object",
        "properties": {
            "key": {
                "description": "API key",
                "type": "string"
            },
            "search": {
                "oneOf": [
                    {
                        "$ref": "#/$defs/TorrentSearchOptions"
                    },
                    {
                        "type": "array",
                        "maxItems": 0
                    },
                    {
                        "type": "array",
                        "prefixItems": [
                            {
                                "$ref": "#/$defs/TorrentSearchOptions"
                            }
                        ],
                        "minItems": 1,
                        "items": false
                    },
                    {
                        "type": "string"
                    }
                ]
            },
            "results": {
                "$ref": "#/$defs/NumericInput",
                "default": 10
            },
            "offset": {
                "$ref": "#/$defs/NumericInput",
                "default": 0
            }
        },
        "required": [
            "key",
            "search"
        ],
        "x-order": [
            "key",
            "search",
            "results",
            "offset"
        ]
    },
    "result": {
        "type": "object",
        "properties": {
            "results": {
                "type": "string",
                "pattern": "^-?\\d+(\\.\\d+)?$"
            },
            "torrents": {
                "type": "object",
                "additionalProperties": {
                    "$ref": "#/$defs/Torrent"
                }
            }
        },
        "required": [
            "results"
        ],
        "additionalProperties": false
    },
    "errors": [
        {
            "code": -32001,
            "message": "Invalid API Key"
        },
        {
            "code": -32002,
            "message": "Call Limit Exceeded"
        },
        {
            "code": -32003,
            "message": "User Account Disabled"
        },
        {
            "code": -32004,
            "message": "IP address needs authorization - please check your notices on BTN"
        },
        {
            "code": -32004,
            "message": "Unauthorized IP address"
        }
    ],
    "examples": [],
    "$defs": {
        "NumericCriterion": {
            "description": "A criterion on a numeric field. Send a bare integer for an exact match, or a string,\nwhich may carry a `>`, `>=`, `<` or `<=` prefix to make the match a comparison rather\nthan an equality, e.g. `\">=3600\"`.",
            "oneOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "string"
                }
            ]
        },
        "NumericInput": {
            "description": "A whole number, sent either as a JSON number or as a string containing one.\n`5` and `\"5\"` are equivalent, and both are accepted wherever this type appears.",
            "oneOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                }
            ]
        },
        "Torrent": {
            "type": "object",
            "properties": {
                "GroupName": {
                    "type": "string"
                },
                "GroupID": {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "TorrentID": {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "SeriesID": {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "Series": {
                    "type": "string"
                },
                "SeriesBanner": {
                    "type": [
                        "string",
                        "null"
                    ]
                },
                "SeriesPoster": {
                    "type": [
                        "string",
                        "null"
                    ]
                },
                "YoutubeTrailer": {
                    "type": [
                        "string",
                        "null"
                    ]
                },
                "Category": {
                    "enum": [
                        "Episode",
                        "Season"
                    ]
                },
                "Snatched": {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "Seeders": {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "Leechers": {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "Source": {
                    "type": "string"
                },
                "Container": {
                    "type": "string"
                },
                "Codec": {
                    "type": "string"
                },
                "Resolution": {
                    "type": "string"
                },
                "Origin": {
                    "type": "string"
                },
                "ReleaseName": {
                    "type": "string"
                },
                "Size": {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "Time": {
                    "type": "string",
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "TvdbID": {
                    "type": [
                        "string",
                        "null"
                    ],
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "TvrageID": {
                    "type": [
                        "string",
                        "null"
                    ],
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "ImdbID": {
                    "type": [
                        "string",
                        "null"
                    ],
                    "pattern": "^-?\\d+(\\.\\d+)?$"
                },
                "InfoHash": {
                    "type": "string"
                },
                "Tags": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "Genres": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "DownloadURL": {
                    "type": "string"
                }
            },
            "required": [
                "GroupName",
                "GroupID",
                "TorrentID",
                "SeriesID",
                "Series",
                "SeriesBanner",
                "SeriesPoster",
                "YoutubeTrailer",
                "Category",
                "Snatched",
                "Seeders",
                "Leechers",
                "Source",
                "Container",
                "Codec",
                "Resolution",
                "Origin",
                "ReleaseName",
                "Size",
                "Time",
                "TvdbID",
                "TvrageID",
                "ImdbID",
                "InfoHash",
                "Tags",
                "Genres",
                "DownloadURL"
            ],
            "additionalProperties": false
        },
        "TorrentSearchOptions": {
            "description": "Every key is optional and matched case-insensitively; unrecognised keys are ignored,\nand choice values that match nothing are silently dropped rather than rejected.",
            "type": "object",
            "properties": {
                "id": {
                    "oneOf": [
                        {
                            "$ref": "#/$defs/NumericCriterion"
                        },
                        {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/NumericCriterion"
                            }
                        }
                    ]
                },
                "group_id": {
                    "oneOf": [
                        {
                            "$ref": "#/$defs/NumericCriterion"
                        },
                        {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/NumericCriterion"
                            }
                        }
                    ]
                },
                "tvdb": {
                    "oneOf": [
                        {
                            "$ref": "#/$defs/NumericCriterion"
                        },
                        {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/NumericCriterion"
                            }
                        }
                    ]
                },
                "tvrage": {
                    "oneOf": [
                        {
                            "$ref": "#/$defs/NumericCriterion"
                        },
                        {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/NumericCriterion"
                            }
                        }
                    ]
                },
                "imdb": {
                    "oneOf": [
                        {
                            "$ref": "#/$defs/NumericCriterion"
                        },
                        {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/NumericCriterion"
                            }
                        }
                    ]
                },
                "time": {
                    "oneOf": [
                        {
                            "$ref": "#/$defs/NumericCriterion"
                        },
                        {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/NumericCriterion"
                            }
                        }
                    ]
                },
                "size": {
                    "oneOf": [
                        {
                            "$ref": "#/$defs/NumericCriterion"
                        },
                        {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/NumericCriterion"
                            }
                        }
                    ]
                },
                "age": {
                    "oneOf": [
                        {
                            "$ref": "#/$defs/NumericCriterion"
                        },
                        {
                            "type": "array",
                            "items": {
                                "$ref": "#/$defs/NumericCriterion"
                            }
                        }
                    ]
                },
                "hash": {
                    "oneOf": [
                        {
                            "type": "string"
                        },
                        {
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        }
                    ]
                },
                "series": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "release": {
                    "type": "string"
                },
                "search": {
                    "type": "string"
                },
                "tags": {
                    "type": "string"
                },
                "require_all_tags": {
                    "type": "boolean"
                },
                "category": {
                    "oneOf": [
                        {
                            "enum": [
                                "Season",
                                "Episode"
                            ]
                        },
                        {
                            "type": "array",
                            "items": {
                                "enum": [
                                    "Season",
                                    "Episode"
                                ]
                            }
                        }
                    ]
                },
                "codec": {
                    "oneOf": [
                        {
                            "enum": [
                                "XViD",
                                "x264",
                                "MPEG2",
                                "DiVX",
                                "DVDR",
                                "VC-1",
                                "H.264",
                                "WMV",
                                "BD",
                                "x264-Hi10P",
                                "H.265",
                                "VP9"
                            ]
                        },
                        {
                            "type": "array",
                            "items": {
                                "enum": [
                                    "XViD",
                                    "x264",
                                    "MPEG2",
                                    "DiVX",
                                    "DVDR",
                                    "VC-1",
                                    "H.264",
                                    "WMV",
                                    "BD",
                                    "x264-Hi10P",
                                    "H.265",
                                    "VP9"
                                ]
                            }
                        }
                    ]
                },
                "container": {
                    "oneOf": [
                        {
                            "enum": [
                                "AVI",
                                "MKV",
                                "VOB",
                                "MPEG",
                                "MP4",
                                "ISO",
                                "WMV",
                                "TS",
                                "M4V",
                                "M2TS"
                            ]
                        },
                        {
                            "type": "array",
                            "items": {
                                "enum": [
                                    "AVI",
                                    "MKV",
                                    "VOB",
                                    "MPEG",
                                    "MP4",
                                    "ISO",
                                    "WMV",
                                    "TS",
                                    "M4V",
                                    "M2TS"
                                ]
                            }
                        }
                    ]
                },
                "source": {
                    "oneOf": [
                        {
                            "enum": [
                                "HDTV",
                                "PDTV",
                                "DSR",
                                "DVDRip",
                                "TVRip",
                                "VHSRip",
                                "Bluray",
                                "BDRip",
                                "BRRip",
                                "DVD5",
                                "DVD9",
                                "HDDVD",
                                "WEB",
                                "BD5",
                                "BD9",
                                "BD25",
                                "BD50",
                                "Mixed",
                                "WEBRip",
                                "WEB-DL",
                                "Unknown"
                            ]
                        },
                        {
                            "type": "array",
                            "items": {
                                "enum": [
                                    "HDTV",
                                    "PDTV",
                                    "DSR",
                                    "DVDRip",
                                    "TVRip",
                                    "VHSRip",
                                    "Bluray",
                                    "BDRip",
                                    "BRRip",
                                    "DVD5",
                                    "DVD9",
                                    "HDDVD",
                                    "WEB",
                                    "BD5",
                                    "BD9",
                                    "BD25",
                                    "BD50",
                                    "Mixed",
                                    "WEBRip",
                                    "WEB-DL",
                                    "Unknown"
                                ]
                            }
                        }
                    ]
                },
                "resolution": {
                    "oneOf": [
                        {
                            "enum": [
                                "Portable Device",
                                "SD",
                                "720p",
                                "1080i",
                                "1080p",
                                "576p",
                                "2160p"
                            ]
                        },
                        {
                            "type": "array",
                            "items": {
                                "enum": [
                                    "Portable Device",
                                    "SD",
                                    "720p",
                                    "1080i",
                                    "1080p",
                                    "576p",
                                    "2160p"
                                ]
                            }
                        }
                    ]
                },
                "origin": {
                    "oneOf": [
                        {
                            "enum": [
                                "None",
                                "Scene",
                                "P2P",
                                "User",
                                "Mixed",
                                "Internal"
                            ]
                        },
                        {
                            "type": "array",
                            "items": {
                                "enum": [
                                    "None",
                                    "Scene",
                                    "P2P",
                                    "User",
                                    "Mixed",
                                    "Internal"
                                ]
                            }
                        }
                    ]
                }
            }
        }
    }
}
