Metadata-Version: 2.4
Name: torbox-sdk
Version: 9.3.1.20261125.4
Summary: Python SDK for the TorBox API
Author-email: TorBox <contact@torbox.app>
License: Proprietary
Project-URL: Homepage, https://api-docs.torbox.app/docs/sdks
Project-URL: Documentation, https://api-docs.torbox.app
Keywords: torbox,debrid,torrent,usenet,sdk
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: urllib3<3.0.0,>=2.1.0
Requires-Dist: python-dateutil>=2.8.2
Requires-Dist: pydantic>=2.11
Requires-Dist: typing-extensions>=4.7.1
Provides-Extra: test
Requires-Dist: pytest>=8; extra == "test"

<!-- Generated by sdk-config (OpenAPI Generator 7.27.0 + hand-written layer) from the TorBox OpenAPI spec. Do not edit. -->
# TorBox Python SDK

Python client for the [TorBox API](https://api-docs.torbox.app). Generated from the
[OpenAPI spec](https://api.torbox.app/openapi.json) and published automatically when the API changes.

```bash
pip install torbox-sdk==9.3.1.20261125.4
```

Python 3.9+. The import name is `torbox`.

## Quick start

```python
from torbox import TorBox

client = TorBox(api_key="YOUR_API_KEY")          # https://torbox.app/settings
me = client.user.get_user_data()                  # returns `data`, typed
print(me.email)

client.torrents.create_torrent(magnet="magnet:?xt=urn:btih:...")
client.torrents.create_torrent(file=("ubuntu.torrent", open("ubuntu.torrent", "rb").read()))
```

Groups: `torrents`, `usenet`, `web_downloads`, `user`, `general`, `notifications`, `rss`, `integrations`, `queued`,
`stream`, `tags`, `assistant`, `vendors`. Every method has the name of its `operationId` (see the
[reference](https://api-docs.torbox.app/reference)); `docs/` lists them all.

## Authentication

The key is sent as `Authorization: Bearer <key>`. The download link endpoints (`request_*_download_link*`) take it
as the `token` query parameter: the client fills it in for you.

```python
url = client.torrents.request_torrent_download_link(torrent_id=123, file_id=0)
```

## Pagination

List endpoints take `offset` and `limit`:

```python
for torrent in client.paginate(client.torrents.get_torrent_list, page_size=100):
    print(torrent.id, torrent.name)
```

## Errors

Every API answer is the envelope `{success, error, detail, data}`. Methods return `data`; anything else raises
`TorBoxError`:

```python
from torbox import TorBoxError

try:
    client.torrents.create_torrent(magnet="...")
except TorBoxError as e:
    e.status   # 403
    e.error    # "PLAN_RESTRICTED_FEATURE"  (stable code, branch on it)
    e.detail   # message you can show to users
    e.data
```

Request validation errors (`422`) have `error == "VALIDATION_ERROR"`. Error codes:
[api-docs.torbox.app/docs/errors](https://api-docs.torbox.app/docs/errors).

## Retries and timeouts

`429` and `503` are retried (default 3 times), waiting for `Retry-After` or backing off exponentially. Every request
has a timeout (default 30 s).

```python
client = TorBox(api_key="...", timeout=10, max_retries=5, base_url="https://api.torbox.app")
client.user.get_user_data(_request_timeout=60)   # per call
```

## Raw access

The generated client is underneath: `client.api_client`, and `client.torrents.get_torrent_list_with_http_info(...)`
returns status, headers and the full envelope without unwrapping.

## Example

[`examples/quickstart.py`](examples/quickstart.py)
