App API
The App API is the interface for the mobile app and for scripts; every address starts with /api/app/v1. It exposes only what an app needs: responses never contain site cookies, API keys, passkeys, passwords, RSS addresses or download links, and addresses inside error messages have their query strings removed. The configuration endpoints are the exception: their field names follow the web endpoints (so keys such as password and cookie appear), secret values are replaced by <已设置> or an empty string, and they need the extra Config permission.
Authentication
Send Authorization: Bearer <token> with every request. Tokens are created under System → API tokens (系统 → API 令牌); see API tokens. A browser that is signed in to the web interface can also call these endpoints, with every permission.
curl -H "Authorization: Bearer $PTT_TOKEN" https://pt-tools.example.com/api/app/v1/overview- No token, or a token that is wrong, expired or revoked: 401.
- A token without the permission the endpoint needs: 403. Below, Read is the permission
app:read, Operate isapp:writeand Config isapp:config(the configuration endpoints also need it). - Tokens work only for the App API: the rest of the web interface (settings, sites, downloaders, notification channels, token management and so on) does not accept them and responds with 401 without a sign-in.
- A device paired through remote access calls these endpoints inside an encrypted tunnel, without a token; its permissions are the ones chosen when it was paired, Full control (Read and Operate) or Read only (Read), neither of which includes Config. The tunnel carries only the App API; the rest of the web interface does not exist there.
Conventions
- Request bodies and responses are JSON. A request body is limited to 1 MiB; a field the endpoint does not know is rejected with 400 rather than ignored.
- Operate endpoints without a body (sign in, search now, delete a subscription) accept no body or
{}; anything else gets 400. - Times are Unix timestamps in seconds. Sizes and uploaded or downloaded amounts are in bytes, speeds in bytes per second, and progress is a percentage from 0 to 100.
- Paged endpoints accept the query parameters
page(starting at 1) andpage_size(20 by default; each endpoint states its maximum) and respond with{"items": [...], "total": count, "page": page, "page_size": size}. - Compatibility:
remote_api_levelinGET /metais currently 1 and goes up only for incompatible changes. New endpoints or fields are not incompatible changes, so clients should ignore fields they do not know. - Contract: the machine-readable description is app-api-v1.yaml (OpenAPI 3.0) in the repository. pt-tools' tests check every endpoint's real responses against it, and the mobile app's Dart models are generated from it.
Errors
An error responds with {"error": "code", "message": "explanation"}. message is a human-readable explanation in Chinese; clients should act on error.
error | Status | Meaning |
|---|---|---|
invalid_body | 400 | The body is not valid JSON, or has a field that is unknown |
invalid_argument | 400 | A parameter is wrong; message says which |
unauthorized | 401 | No valid token |
forbidden | 403 | The token lacks this permission |
not_found | 404 | The endpoint, site or subscription does not exist |
method_not_allowed | 405 | The endpoint exists but not with this method; the Allow header lists the accepted ones |
busy | 409, 503 | The same thing is in progress (409, such as signing in to a site); too many image requests (503, with Retry-After) |
conflict | 409 | When changing configuration, the endpoint that saves it reported a conflict (such as a brush task running a round) |
rate_limited | 429 | TMDB is rate limiting; try again later |
internal | 500 | An internal error in pt-tools |
search_failed, download_failed, attend_failed, upstream | 502 | Searching, downloading a torrent file, signing in, reaching TMDB or reading a downloader failed, or saving a configuration failed |
unavailable | 503 | The service behind the endpoint is not running |
timeout | 504 | The work did not finish within the time limit (organising into a library, reading a downloader's torrent list) |
assistant_disabled, decided | 409 | The AI assistant is not enabled; this pending action has already been decided |
too_many | 429 | The AI assistant is answering too many questions at once |
Endpoints
| Method | Path | Permission | Purpose |
|---|---|---|---|
| GET | /meta | Read | Version, compatibility level, feature groups and the caller's own permissions |
| GET | /overview | Read | Totals across enabled sites and today's changes |
| GET | /sites | Read | Sites, login status, today's sign-in and your statistics on each site |
| POST | /sites/{site}/attend | Operate | Sign in now |
| GET | /favicon/{site} | Read | Site icon |
| GET | /torrents | Read | Torrents in the downloaders |
| GET | /downloaders | Read | Downloaders with their current speed and free space |
| GET | /downloaders/seeding | Read | How many torrents each downloader is seeding and their size |
| GET | /downloaders/{id}/labels | Read | The categories and tags a downloader has (to choose from when pushing) |
| POST | /torrents/actions | Operate | Pause, resume and delete torrents |
| POST | /torrents/purge/scan | Operate | Look for other hard links and related torrents before deleting one completely |
| GET | /torrents/purge/scans/{id} | Read | Progress and result of that search |
| POST | /torrents/purge | Operate | Delete a torrent completely using the search result |
| POST | /search | Read | Multi-site search |
| POST | /push | Operate | Push a search result to a downloader |
| GET | /free-watches | Read | Wait-for-free records |
| POST | /free-watches/batch | Operate | Register wait-for-free in bulk (dry_run only computes) |
| POST | /free-watches/{id}/cancel | Operate | Cancel a waiting record |
| GET | /tasks | Read | Task list (push records) |
| GET | /brush/tasks | Read | Brush tasks |
| GET | /brush/stats | Read | Brush earnings by day, week, month, quarter or year |
| GET | /media/history | Read | Organise history |
| POST | /media/history/{id}/retry | Operate | Organise the torrent of one history record again |
| POST | /media/history/{id}/scrape | Operate | Scrape the movie or show of one history record again |
| GET | /media/libraries | Read | Media libraries |
| GET | /media/libraries/{id}/items | Read | Movies and shows organised into one library |
| POST | /media/recognize | Read | Recognise a torrent title |
| POST | /media/organize/preview | Read | Preview organising a torrent in a downloader |
| POST | /media/organize | Operate | Organise a torrent in a downloader into a media library |
| GET | /subscriptions | Read | Subscriptions |
| GET | /subscriptions/{id} | Read | A subscription with its episodes and downloaded torrents |
| POST | /subscriptions | Operate | Create a subscription |
| POST | /subscriptions/{id}/status | Operate | Pause or resume a subscription |
| POST | /subscriptions/{id}/search | Operate | Search now |
| PUT | /subscriptions/{id} | Operate | Change a subscription's settings (follow schedule, version lock and so on) |
| DELETE | /subscriptions/{id} | Operate | Delete a subscription |
| GET | /subscriptions/{id}/episodes | Read | Each episode of a followed show |
| POST | /subscriptions/{id}/episodes/{n}/skip | Operate | Skip an episode, or want it again |
| POST | /subscriptions/{id}/episodes/{n}/unlock | Operate | Let one episode use another version (outside the version lock) |
| GET | /subscriptions/{id}/runs | Read | A subscription's run history |
| POST | /subscriptions/{id}/torrents/{tid}/organize | Operate | Organise one torrent the subscription downloaded again |
| POST | /subscriptions/{id}/torrents/{tid}/scrape | Operate | Scrape one torrent the subscription downloaded again |
| POST | /subscriptions/schedule/preview | Read | When a schedule will search next |
| GET | /subscriptions/{id}/episode-rules | Read | Episode-number rules of a followed show |
| PUT | /subscriptions/{id}/episode-rules | Operate | Set the episode-number rule for a release group |
| DELETE | /subscriptions/{id}/episode-rules | Operate | Delete the episode-number rule for a release group |
| GET | /explore | Read | Explore: TMDB trending, popular and search |
| GET | /images/tmdb/{size}/{file} | Read | A TMDB image (poster), fetched by pt-tools |
| GET | /updates | Read | Whether a newer release exists |
| GET | /assistant/status | Read | Whether the AI assistant is on, its model, and whether you can confirm |
| GET | /assistant/conversations | Read | Your AI assistant conversations |
| POST | /assistant/conversations | Read | Create a conversation, optionally sending the first message |
| GET | /assistant/conversations/{id} | Read | A conversation's messages and pending actions |
| DELETE | /assistant/conversations/{id} | Read | Delete a conversation |
| POST | /assistant/conversations/{id}/messages | Read | Send a message; the answer is generated in the background |
| POST | /assistant/conversations/{id}/cancel | Read | Stop the answer |
| GET | /assistant/conversations/{id}/events | Read | Long-poll a conversation's progress |
| POST | /assistant/confirmations/{id} | Operate | Confirm or deny an action |
| GET | /templates | Read | Message templates: events, variables and the current templates |
| POST | /templates/preview | Read | Render a template with sample data |
| PUT | /templates/{type} | Operate | Save the template for an event |
| DELETE | /templates/{type} | Operate | Restore the default |
| GET | /config | Config + Read | Configuration catalog: what can be read and changed, operations and fields |
| GET | /config/{resource} | Config + Read | Current values of one kind of configuration (secrets masked) |
| POST | /config/{resource}/preview | Config + Read | Preview a change: before, after and impact |
| POST | /config/{resource}/changes | Config + Operate | Save a change |
Paths leave out the /api/app/v1 prefix. Search, recognition, the organise preview, the template preview and the configuration preview send their content with POST but need only Read. Every call a token makes to an Operate endpoint, including calls refused for lack of permission, is recorded under ChatOps → Audit log (操作审计) with the channel API token (API 令牌); a push that was stopped and batch actions with failures are recorded as errors even though the response is 200.
Basics
GET /meta
{
"name": "pt-tools",
"version": "v1.0.0",
"remote_api_level": 1,
"features": [
"overview",
"sites",
"torrents",
"downloaders",
"tasks",
"search",
"push",
"attendance",
"brush",
"media",
"subscriptions",
"updates",
"assistant",
"templates"
],
"principal": { "kind": "api_token", "name": "My phone", "scopes": ["app:read", "app:write"] }
}principal.kind is api_token (a token), session (a web sign-in) or remote_device (a device paired through remote access); features lists the feature groups of this version (earlier versions have no downloaders, updates, assistant or templates); scopes are the caller's permissions, so a client can decide which actions to show.
GET /updates
Whether a newer release exists: current_version, has_update, new_releases (each with version, name, published_at, url and changelog, plus prerelease: true for previews) and checked_at. With include_prerelease=1 preview releases count too. The result is cached for a while instead of asking GitHub every time; it never upgrades. When it cannot check and has no earlier result it returns 502 (upstream).
Overview and sites
GET /overview
totalsadds up the enabled sites:uploaded,downloaded,ratio,seeding,leeching,bonus,bonus_per_hour,seeding_size,site_count,unread_messages.todayholds today's changes:from,to,uploaded,downloaded,bonus, with per-site changes insites. They are counted the same way as in Statistics. When today's changes cannot be computed,today.errorgives the reason, and the zeros do not mean there was no traffic today.updated_atis when the site statistics were last updated.- Every
downloadedhere is the billed download: what the site counts toward your ratio after free and discount promotions, not the amount actually transferred. Thetodaychanges come from the daily snapshots, which keep only the billed figure. See Two kinds of download figures.
GET /sites
The response is {"items": [...], "user_error": "…"}: items has one item per site; when your statistics on the sites cannot be read, user_error gives the reason and no item has user.
| Field | Content |
|---|---|
name, display_name, enabled | The site's identifier, display name and whether it is enabled |
login | Login status: tier is the reminder level (none, 30d, 14d, 7d, 3d, banned-imminent, or unknown when there is no access record), days_remaining is the number of days left before the site's inactivity limit, plus last_active_at, last_probe_at and last_probe_status |
attendance | Today's sign-in: supported, enabled, day, status (pending, signed, already, failed, unsupported), message, last_attempt_at |
user | Your statistics on the site, absent until they have been fetched: username, level, uploaded, downloaded, ratio, bonus, bonus_per_hour, seeding, leeching, seeding_size, unread_messages, hnr_unsatisfied, updated_at |
The downloaded in user is also the billed download, not the amount actually transferred.
POST /sites/{site}/attend
Signs in to the site now and responds with the same object as attendance in /sites. If a sign-in for the site is already running, it responds with 409.
GET /favicon/{site}
The site icon shown in the web interface. The response is an image, not JSON.
Downloaders
GET /downloaders
The enabled downloaders: id, name, type (qbittorrent or transmission), default, reachable (status or free space could be read this time), error (why not), version, upload_speed, download_speed, uploaded, downloaded (the downloader's own totals) and free_space. No downloader address, username or password.
GET /downloaders/seeding
The torrents each enabled downloader is seeding, the same figures as Downloader seeding on the User Stats page of the web UI. Each item has id, name, type, reachable (the torrent list could be read), error (why not, with addresses removed), seeding_count and seeding_size (torrents whose state is seeding), and idle_count and idle_size (completed torrents that are paused, stopped, queued, being checked or in error); total_seeding_count and total_seeding_size add up the downloaders that could be read. Sizes are summed per torrent, so a reseed and its original count once each and the total is larger than the disk space used. The full torrent list of every downloader is read, waiting at most 20 seconds in all; a downloader not read by then says so. The endpoint exists when features from GET /meta contains downloader_seeding.
GET /downloaders/{id}/labels
The categories and tags an enabled downloader (id from GET /downloaders) already has, for the app to offer when pushing. pt-tools reads the downloader's torrent list and collects the categories and tags used on its torrents, without empty or duplicate entries, sorted; categories created in qBittorrent that no torrent uses yet are listed too. The response has downloader_id, downloader, type, supports_category, categories and tags. Transmission has no categories: a category given when pushing becomes its first label, so supports_category is false, categories is empty, and the labels on its torrents are all in tags. It responds with 404 when the downloader does not exist or is disabled, with 502 (upstream, the reason without addresses) when the downloader can't be reached or its torrent list can't be read, and with 504 (timeout) when reading takes longer than 15 seconds. The endpoint exists when features from GET /meta contains downloader_labels.
GET /torrents
| Parameter | Description |
|---|---|
downloader_id | Only this downloader |
state | downloading, seeding, paused, stopped, queued, checking or error |
q | A keyword in the title |
sort, order | The sort field (added_at, completed_at, title, progress, size, ratio, state, upload_speed, download_speed, eta, seeds) and asc or desc; newest added first by default |
page, page_size | page_size is at most 200 |
Each item has downloader_id, downloader, task_id, info_hash, title, progress, size, state, ratio, seeds, peers, upload_speed, download_speed, eta (estimated seconds left, -1 when it cannot be estimated), added_at, completed_at, category, tags and save_path. failures lists the downloaders whose torrents could not be read (downloader_id, downloader, error); when it is not empty, the list is incomplete.
POST /torrents/actions
{ "action": "pause", "targets": [{ "downloader_id": 1, "task_id": "task_id from /torrents" }] }action is pause, resume, delete (removes the torrent and keeps its data) or delete_with_files (removes the data too; when other torrents outside the batch in the same downloader still use the data, such as a cross-seed, or when the file list cannot be read to confirm it, only the torrent is removed and the data kept, and the result's message says so; when the downloader's torrents cannot be read, nothing is removed and the result is a failure); targets holds 1 to 100 torrents. The response has succeeded, failed and per-torrent results (downloader_id, task_id, success, message).
Deleting a torrent completely
Library files are usually hard links: deleting a torrent with its data leaves the library files in place, so no space comes back. Deleting completely removes the torrent with its data, the files it organised into the library, related torrents (seeding copies) that use the same files, and the other hard links found in the folders pt-tools can see (media libraries, watched folders, the local folders of path mappings, the torrents' save folders), with the same rules as Delete completely on the web title page. These three endpoints exist when features from GET /meta contains torrent_purge. Paths in the responses are only file names and the name of the folder they were found under, never full paths.
POST /torrents/purge/scan { "downloader_id": 1, "task_id": "task_id from /torrents" }: starts the search in the background and returns it at once (the same shape as GET /torrents/purge/scans/{id}). Searching the same torrent again within 30 minutes returns the same search. It responds with 404 when the torrent is not in the downloader and with 503 when the organise service is not running or the torrent's downloader cannot be read. A result from a search during which a downloader could not be read is not reused; searching again starts a new one.
GET /torrents/purge/scans/{id}: status is queued, running, done or failed (with the reason in error), and scanned is how many files have been looked at. torrent is the torrent itself (present says whether it is still in the downloader; when deletable is false it is protected and why says why; when keep_data is not empty, deleting removes only the torrent and its data stays, for the reason given; related torrents carry it too); files are the files it organised into the library (name, library, mode, size, season, episode; when deletable is false the file is not deleted this time, for example a moved file is the only copy, and note says why); subscriptions are the subscriptions that downloaded it. Once the search is done, extras are the other links (name, root, size; used_by lists the torrents using the link: related torrents, torrents that use only some of these files and torrents that might be using them; when one of them is not being deleted, the link stays), kept are files used by other organize records (name, root, and label with that record's title and episode, for example the episode the original of a seeding copy was organised into: they are not deleted and stay afterwards), related are the related torrents using the same files (files holds the file names they use), partial are torrents that use some of these files and have other files too (other files, other_bytes bytes, for example a season pack: they are not deleted, and the links they use stay), and unknown are torrents that might be using these files (their file list cannot be read, or their paths cannot be mapped to local paths but file names and sizes match; why says which; they are not deleted, and the links they cover stay); when unreachable is not empty, Delete completely cannot run this time (a downloader cannot be read, or the searched folders include the same disk mounted twice; once the search is done, each read checks the downloaders again), and notes explain how the check was made; unseen is how many links are where pt-tools cannot see (in unseen_files files, whose space will not come back); incomplete is true when the search did not finish, and unsupported is true when this system cannot search (only the recorded files and the torrents are deleted). Search results are kept for 30 minutes; an expired search or one that is not for a torrent returns 404.
POST /torrents/purge:
{
"scan_id": "from the search",
"confirm_protected": [{ "downloader_id": 1, "hash": "a protected torrent you confirm" }],
"subscription": "pause"
}pt-tools first reads every downloader again: when one cannot be read, or the searched folders include the same disk mounted twice, it responds with 503 and deletes nothing. Then it pauses the subscriptions that downloaded the torrent (keep leaves them alone; the default is pause), deletes the torrent and the related torrents that the search listed and that still use these files (all with their data; protected ones only when listed in confirm_protected; when a torrent that is not being deleted uses the same path, or another organise record uses the file, only the torrent is deleted and its data stays), deletes its organise records with their files (not those whose deletable is false), and the other links last: each link is checked again right before deletion (still the file that was found, not a symbolic link) and folders left empty are removed too; links a torrent or another organise record still uses at that moment stay. It responds with 400 when the search has not finished, 404 when the search result has expired, and 409 (stale) when the files organised from this torrent, the torrents or the path mappings changed after the search, or a torrent that the search did not list now uses these files; search again (in the latter case the search is discarded, so the next search is a new one). The response has the steps (kind is subscription, torrent, file or links, with target, ok, message) and failed, the other links in extra_steps (name, root, ok, message; skipped is true for a link kept on purpose, for example because a torrent still uses it, which does not count as a failed step), the space freed in freed_bytes, and the files whose space did not come back in left (name, remaining paths still there, missing links where pt-tools cannot see, null when unknown). Complete deletions made with a token or a remote device are written to the audit log.
Search and push
POST /search
| Field | Description |
|---|---|
keyword | Required, up to 100 characters |
sites | Search only these sites, up to 100; when empty, every enabled site is searched, and when none of the listed sites is enabled nothing is searched |
category | Category |
free_only | Free torrents only |
min_seeders | Minimum number of seeders |
section | M-Team only: normal for the general section, adult for the adult section; empty means general. Other sites ignore it |
The response:
itemsare the results. Each hassite,torrent_id,title,subtitle,info_hash,size,seeders,leechers,snatched,uploaded_at,category,tags,discount,discount_end_at,free,has_hr,imdb_idanddouban_id. There are no detail-page or download links; push withPOST /push.sitesis the number of results per site,errorslists the sites that failed (site,error), andduration_msis how long the search took. A search waits at most 30 seconds.
POST /push
Pushes one torrent to a downloader: pt-tools downloads the torrent file from the site, then applies the same disk space protection and site seeding capacity checks as an RSS push.
| Field | Description |
|---|---|
site, torrent_id | Required, taken from a search result |
downloader_id | The downloader to push to; when empty, the default downloader, or the first enabled one if there is no default |
title, category, tags, save_path | Optional: the title for the record (the name in the torrent file when empty), and the category, tags and save folder in the downloader |
save_path is a folder as the downloader sees it; when empty, the downloader's own default folder is used. The folders preset for each downloader under Downloader settings in the web UI are in directories from GET /mobile/options. Separate several tags with commas. The categories and tags a downloader already has come from GET /downloaders/{id}/labels; when pushing to Transmission, category becomes the first label.
The response has success, skipped (the downloader already has this torrent), message, info_hash, downloader_id and downloader. When disk space protection or the site seeding capacity stops the push, success is false and message gives the reason, still with status 200; when the torrent file cannot be downloaded, the status is 502. If the torrent was found by a search shortly before, its size, H&R, free status and free expiry from the search result are recorded with the task (H&R protection and free-expiry cleanup use them).
Waiting for free
These endpoints exist when features in /meta contains free_watch. Registering in bulk only writes wait-for-free records and never pushes: once a torrent is free, the background check reads its details again and pushes it through the usual free check and push gates, see waiting for free.
GET /free-watches
Wait-for-free records, newest first. Query parameters: status (watching, pushed, expired, canceled, failed), source (manual single web registration, batch web multi-select, app App API, search a search subscription on the web; manual also covers older records without a source), site (case-insensitive), torrent_id, q (searches titles, up to 100 characters), page, page_size (at most 100). The response has items, total, page, page_size and counts (records per status, not affected by the filters). Each record has id, site, torrent_id, title, size, has_hr, downloader_id, downloader, status, source, message (the last check's result), check_count, failures, next_check_at, last_check_at, expires_at, info_hash (the hash after the push) and more; times are Unix seconds. An ended record has end_reason (pushed pushed once free, duplicate already in the downloader at push time, elsewhere downloaded elsewhere, expired ended, failed could not be read repeatedly, user cancelled, blocked blocked, replaced replaced by a newer release from the same search subscription); a record whose discount was read has last_discount (NONE, FREE, 2XFREE, PERCENT_50 and so on) and last_discount_end_at, and one that was seen free has first_free_at.
POST /free-watches/batch
Registers up to 200 torrents at once. With dry_run set to true nothing is saved, and the response is the same as for a real registration.
| Field | Description |
|---|---|
items | Required; each has site and torrent_id, optionally title, subtitle, size, has_hr, info_hash |
downloader_id | The downloader to push to; empty means the default downloader (as for POST /push) |
save_path, category, tags | Save directory, category and tags used for the push |
days | How long to wait, 1 up to the longest wait in the settings (30 by default, up to 365); without it, the default wait in the settings (7 by default) |
dry_run | Only compute, save nothing |
For torrents found by a recent search, the title, size and H&R are filled in from the search results; when no title can be filled in, the name in the torrent file is used when it is pushed. The response has created (how many were registered; for a dry run, how many would be), skipped (counts per reason), total_size, unknown_size, watching, limit, downloader_id, downloader, and per-torrent items: result is created, would_create or skipped; a skipped one has one of the reason values below and a message with details, and for exists the id of the existing record.
reason | When a torrent is skipped |
|---|---|
invalid | No site, or the id is not made of letters, digits and ._- |
duplicate | It appeared earlier in the same batch |
site_unsupported | The site is not enabled or cannot read torrent details |
exists | The same torrent already has a wait-for-free record (in any state) |
pushed | The torrent records show it was pushed (including RSS pushes and archived records), or the same hash was pushed |
blocked | It is blocked (a block that applies to every title) |
limit | The number of waits is at the limit (200) |
The audit gets one row whose arguments are only dry_run, the number of items, created and skipped, without titles. A dry run, or a batch whose skips are only deduplication (exists, pushed, blocked, duplicate), records success; when items were skipped for limit, site_unsupported or invalid, it records error:partial if some were registered and error:none_created if none were.
POST /free-watches/{id}/cancel
Cancels a waiting record. The body can be omitted or be {"reason": "in library"} (up to 100 characters, written into the message as 取消了:in library). The response is the cancelled record; an unknown id returns 404, and a record that is no longer waiting returns 409 conflict.
A typical script does a dry_run first to see the summary, then registers for real; filters such as "already in the library", cloud drives or actors stay in the script. To undo one torrent, find its id with GET /free-watches?site=mteam&torrent_id=912345&status=watching, then call cancel with a reason.
Task list
GET /tasks
Push records, newest first.
| Parameter | Description |
|---|---|
site | Only this site |
q | A keyword in the title |
pushed | 1 for pushed records only |
page, page_size | page_size is at most 100 |
Each item has id, site, torrent_id, title, size, category, tags, free, free_level, free_end_at, has_hr, pushed, pushed_at, downloader, progress, completed, completed_at, source, error and created_at. source says where the record came from: RSS is free_download or filter_rule; the others are manual_push (pushed from the web interface), app_push (pushed from the app), brush, subscription, transfer (torrent transfer) and reseed.
Brush
GET /brush/tasks
One item per brush task: id, name, enabled, site, site_enabled, downloader, active (torrents being brushed), downloading (of those, the ones still downloading), active_size, and the results for today and total (uploaded, downloaded, added, removed). When the task is enabled and its run windows pause adding right now, the item also has add_paused, a note for people (for example 暂停加种,17:30 起恢复, in the host's time zone); it is absent when the task may add, has no windows or is disabled.
GET /brush/stats
Earnings of all brush tasks in total and per task over recent periods, counted the same way as on the web page; see Earnings and the daily report (host time zone, weeks start on Monday). The endpoint exists when features from GET /meta contains brush_stats.
granularity is day, week, month, quarter or year (default day); periods defaults to 30, 12, 12, 8 and 5 and is capped at 366, 104, 60, 40 and 20; values out of range return 400. The web endpoint's days is not accepted.
The response has granularity, periods, from and to; totals holds each period of the total, and tasks holds each task's id, name and periods. Every period has start and end (its first and last day) plus uploaded, downloaded, added and removed. The last period is the current one: end is its natural end date and may be after today, while earnings only count up to today.
Media
These endpoints match Media (媒体) in the web interface; see Follow and subscribe and Media library organising. Creating subscriptions and Explore use TMDB; without a usable API key they respond with 400, see TMDB API key.
GET /media/history
Organise history, most recently updated first. Parameters: status (done, failed, skipped, removed), q (keyword), page and page_size (at most 100). Each item has id, media_type, tmdb_id, title, year, season, episode, episode_end, torrent_name, library, target_path, mode, size, status, message and created_at.
POST /media/history/{id}/retry
Organises the torrent of this record again (usually a failed one). An entry and library chosen by hand earlier are kept; an entry that came from recognition is replaced when a correction now matches, and the torrent's organised files whose entry came from recognition move to the new location as well (in the response's plan those items are done, and changed counts them; to see beforehand which ones would move, call POST /media/organize/preview, where they are change). Responds like POST /media/organize. A missing record gets 404.
POST /media/history/{id}/scrape
Scrapes the movie or show of this record again (every history record of the same title in this library), writing the NFO and images the library's current scrape settings ask for; locked fields stay as they are. The response has records (history records scraped), written (files written), messages and queued (still running in the background; check the history later). It responds with 400 when the library has scraping turned off or the record is not organised, and 404 when the record is missing.
GET /media/libraries
One item per library: id, name, kind (movie or tv), anime (anime only), path (the library folder as pt-tools sees it), mode (organise mode; empty means the default from the organise settings), scrape, classify_dir (put files into sub-category folders), overwrite_mode (empty never replaces an old version, larger replaces it with a larger file) and enabled, plus the download settings filled in when creating a subscription: download_downloader_id (0 means none), download_save_path, download_category and download_tags (empty means none), see download settings for new subscriptions.
GET /media/libraries/{id}/items
What has been organised into one library (id from GET /media/libraries; disabled libraries can be read too), merged by title: one item per movie and one per season of a show. Files organised into the library and imported existing files both count; failed, skipped and removed records, and records without a recognised title, do not. The most recently added come first, paged like the other lists (page, page_size up to 100). Each item has media_type, tmdb_id, title (the title recorded when organising, or TMDB's when none was recorded), year, season (0 for movies), episodes (the episode numbers in the library, ascending and without duplicates; an empty array for movies), files (how many files were organised), size (their total size), poster_path (TMDB's relative poster path, fetched with GET /images/tmdb/{size}/{file}; absent when it can't be read) and latest_at (when the latest file was added). No paths or torrent names.
q searches the titles recorded when organising: an item is listed when one of its records has a title containing q, and files, size and episodes still cover the whole item; a title filled in from TMDB for display only is not searched. Posters come from TMDB (cached) with at most 8 seconds per page; items whose poster can't be read have no poster_path, and the response still succeeds. It responds with 404 when the library does not exist, and with 400 for a bad id, paging, or a q longer than 200 bytes. The endpoint exists when features from GET /meta contains media_library.
POST /media/recognize
{"title": "…", "subtitle": "…", "imdb_id": "tt…"}: give at least one of the torrent title and subtitle (up to 512 characters each); imdb_id is the IMDb ID the site gives, optional. Recognition follows the rules of Media recognition (corrections, recognition words, IMDb ID, then a search by name) and changes nothing. Responds with:
summary: one readable line (name, year, season and episode);meta: what the title parsed into, such asname_cn,name_en,year,type,season,episode,episode_end,resolution,source,video_codec,hdr,audioandgroup;match: the TMDB entry (id,media_type,title,original_title,year,overview,poster_path,vote_average,imdb_id), absent without a reliable match;source:override(corrected by hand),imdb,searchornone;score;candidates: up to 5 candidates (withscore);message: a note (for example that without a usable TMDB API key only the title was parsed);error: why TMDB failed.
POST /media/organize/preview
{"downloader_id": 1, "hash": "…"}: a torrent in a downloader; use info_hash from GET /torrents as hash (task_id when there is no info_hash). Add media_type and tmdb_id together to choose the TMDB entry, and library_id to choose the library; without them pt-tools recognises the torrent and picks the library by type. Only the plan is computed; nothing changes. Responds with:
downloader_id,downloader,hash,name(the torrent name),match(as above),library(id,name),category(the sub-category) andmode;items: one per video, withrel(path inside the torrent),size,target(where it goes in the library),season,episode,episode_end,status(pendingto organise,donealready in the library,existsthe target is taken by another file,replacereplaces an older version pt-tools put there,changeorganised before under another entry and moving to the new target this time,failedcannot be organised) andmessage;changeitems, anddoneitems whose entry changed but which stay put, also carry what they were organised as:prior_target(the old location; when it equalstargetonly the record changes and the title is scraped again),prior_media_type,prior_tmdb_idandprior_title;skipped: how many files are left out (samples, too small, not video);problem: when set, the whole torrent cannot be organised (for example the files are not found and a path mapping is needed).
POST /media/organize
Same parameters as the preview. Organises the torrent the library's way (hard link, copy or move), scrapes and asks the media servers to scan, like organising by hand on the web page. Responds with plan (as in the preview), created (files organised this time), done, skipped, failed, changed (files moved to another entry, not counted in created), messages and queued (still running in the background; check the history later). When everything fails the response is still 200 and the audit log records an error. Organising waits at most 60 seconds; after that it responds with 504 (timeout) and keeps going in the background.
GET /subscriptions
Parameters: status (active, paused, pending, done) and q (keyword). Each item has:
id,media_type(movieortv),tmdb_id,season,title,original_title,year,total_episodes;poster_path: the TMDB poster path; fetch the image withGET /images/tmdb/w342/<the path without its leading />(w342can also be one of the other sizes listed below), see below;status,upgrade(whether to upgrade quality),source(manual,explore,douban,chatops,app),message,last_search_at,next_search_at,created_at;- where to look and where to push:
profile_id(the quality profile; 0 uses the default from the settings),sites(search only these sites; empty means all),downloader_id(0 uses the one from the settings),category,tags(comma-separated) andsave_path(empty uses the downloader's default); progress:total,required(episodes to follow: from the start episode on, not skipped),aired,in_library,downloading,waiting(episodes waiting for the locked version, also counted inmissing),skipped(episodes not followed) andmissing(the missing episode numbers);- the follow settings of a TV show:
schedule(see below),lock_version(the version lock),lock_groupandlock_resolution(the locked release group and resolution, empty until decided),start_episode(the episode to start from; 0 and 1 mean the whole season),follow_next_season(follow the next season when this one is done),next_season_id(the subscription created for the next season),library_id(the media library to organise into; 0 picks one by type) andcompleted_at(when it was done).
Schedule
schedule is when to search actively:
| Field | Description |
|---|---|
kind | Empty uses the global search interval; airtime follows the air time; interval every so often; daily every day; every_days every few days; weekly on weekdays; monthly on days of the month; cron by a cron expression |
at | The time HH:MM in the time zone of the machine pt-tools runs on. With airtime it is when the episode airs (TMDB only has the date); empty means 20:00, also for the other kinds |
every | The number of days for every_days, 1 to 30 |
days | The weekdays for weekly (0 to 6, 0 is Sunday) or the days of the month for monthly (1 to 31; a shorter month uses its last day) |
air_delay_hours | With airtime, how many hours after airing to start searching (0 to 72; 0 means 2 hours) |
air_retry_hours | With airtime, how many hours to wait before searching again when nothing was found (0 to 48; 0 means 6 hours) |
air_window_days | With airtime, for how many days after airing to retry at that interval (0 to 60; 0 means 7 days); after that a missing episode is searched once a day |
interval_minutes | With interval, the minutes between searches, 30 to 10080 (7 days), counted from the last search |
cron | With cron, the expression: 5 fields (minute hour day month weekday); separate several with semicolons and the earliest one due wins. See Subscriptions and following for the syntax. The normalised form is stored |
airtime is for TV only. A new TV subscription without a schedule follows the air time. Scheduled searches get a few minutes of random offset, and two searches are at least 30 minutes apart.
POST /subscriptions/schedule/preview
Shows when a schedule will search next (read-only, needs Read). The request is {"schedule": {...}, "media_type": "tv", "subscription_id": 1, "count": 5}: schedule is required; with subscription_id, that subscription's type and creation time are used (every few days counts from the day it was created); count is how many times to list (1 to 10, 5 by default). The response is {"next": [Unix seconds…], "note": "…"} without the random offset. A schedule that follows the air time has no times, and note explains how it is worked out. A wrong schedule gets 400 with a message saying what is wrong (for example which field of the cron expression).
GET /subscriptions/{id}
The subscription's own fields, plus:
episodes: each episode of a TV season, withnumber,name,air_date,state(library,downloading,missing,waiting_version(waiting for the locked version),upcomingorskipped(not followed)),source(where the state comes from:library,subscriptionfor a torrent the subscription pushed,downloaderfor a torrent already in the downloader),version(the current version: release group and resolution),manual_skip(skipped by hand) andmanual_unlock(this episode is outside the version lock);torrents: the torrents it downloaded, withid(thetidof the two endpoints below),site,torrent_id,title,status(downloading,done,failed,replaced),episode,episode_end,complete,size,message,created_at, and:files: how the torrent was organised into the library, one item per video file:id(the history record, usable with/media/history/{id}/…),name(the file name),episode,episode_end,status(done,failed,skipped,removed),message(why it was not organised),scrape_status(ok,partial,failed; empty when never scraped),scrape_note,next_retry_at(when it is retried automatically) andretrying(the organise queue is retrying it now); an empty array before the torrent is organised;can_organize: it can be organised again (a file that was not organised and is not being retried, or the torrent was marked failed and has no history yet);can_rescrape: it can be scraped again (a file is organised). Both arefalsefor an old version replaced by an upgrade.
POST /subscriptions
| Field | Description |
|---|---|
media_type | Required, movie or tv |
tmdb_id | Required, the TMDB ID |
season | The season number for TV; the latest season when empty |
profile_id | The quality profile; the default from the settings when empty |
upgrade | Whether to upgrade quality |
sites | Search only these sites; all sites when empty. They must be configured and enabled; unknown names get 400 |
downloader_id | The downloader to push to; the one from the settings when empty. An unknown ID gets 400 |
category, tags, save_path | The category, tags (comma-separated) and save directory for pushes; the downloader's defaults when empty |
A TV subscription follows the show and can also carry:
| Field | Description |
|---|---|
schedule | The schedule (see above); follows the air time when empty |
lock_version | The version lock: once the first episode is chosen, only the same release group and resolution (it waits rather than switching to another version); on when empty |
lock_group, lock_resolution | Lock a release group and resolution from the start (only with lock_version on; leave one empty to not restrict it); when not given, the first release that downloads becomes the lock. lock_group is at most 64 characters and lock_resolution at most 16 bytes |
start_episode | The episode to start from; earlier episodes are not wanted |
follow_next_season | Follow the next season when this one is done |
library_id | The media library to organise into; picked by type when empty or 0 |
from_torrent | Start following from a torrent on a site: site, torrent_id and an optional title (used as the keyword to search that site only when the cached search results do not have the torrent). The start episode defaults to the torrent's episode, and the torrent is pushed right after creation (not when it fails the quality profile or those episodes are already there; the reason goes into the subscription's message) |
The response is the new subscription, with the source app. It responds with 400 when the title is already subscribed and 404 when TMDB does not have it. With from_torrent it fetches the torrent from the site and pushes it, so the response takes longer.
PUT /subscriptions/{id}
Changes a subscription's settings. Only the fields given change (a field left out or given as null stays as it is); the title and season cannot. It takes profile_id, upgrade, sites (an empty array means all sites; null leaves it unchanged), downloader_id, category, tags, save_path and, for a followed show, schedule, lock_version, lock_group, lock_resolution, start_episode, follow_next_season, library_id and total_episodes (the number of episodes in the season: used when greater than 0; 0 goes back to TMDB's count). Giving empty strings for both lock_group and lock_resolution clears the locked version, which is then decided again by the next download.
When the schedule, version lock, start episode or episode count changes, every episode is worked out again under the new settings, a search runs soon, and the run history records the change. The response is the updated subscription.
GET /subscriptions/{id}/episodes
Each episode of a followed show (the same as episodes in the subscription detail). A movie has no episodes and responds with 400.
POST /subscriptions/{id}/episodes/{n}/skip
{"skip": true} skips episode n (not followed: it is not missing and does not hold up completion); {"skip": false} wants it again. The response is every episode after the change.
POST /subscriptions/{id}/episodes/{n}/unlock
{"unlock": true} lets episode n use another version (for when the locked version does not turn up; pt-tools searches once right away); {"unlock": false} puts it back under the lock. The response is every episode after the change.
GET /subscriptions/{id}/runs
The subscription's run history, newest first, with the parameters page and page_size (1 to 100). Each active search, RSS match, creation and change by hand records one run: id, trigger (create, schedule, rss, manual, ai), started_at, finished_at, status (ok, nothing, waiting, failed, partial; a change by hand is changed), summary, steps (each step's kind and text; kind is search, reject, lock, push, fail, adopt, wait or info) and steps_truncated (too many steps; the rest were not recorded). Each subscription keeps its latest 100 runs for at most 90 days. Downloader addresses are removed from the text.
POST /subscriptions/{id}/torrents/{tid}/organize
Organises one torrent the subscription downloaded again (tid is the id in the detail's torrents; a season pack works the same as a single episode, one torrent at a time). It uses the subscription's title and library instead of recognising the name, and leaves files already organised alone. A torrent marked failed goes back to waiting for organising (the 7 days start again), and is marked in the library as soon as organising succeeds. Responds like POST /media/organize and records a run. A torrent of another subscription gets 404; a torrent without a recorded downloader or info hash, or an old version replaced by an upgrade (its files were removed from the library on purpose), gets 400.
POST /subscriptions/{id}/torrents/{tid}/scrape
Scrapes the movie or show this torrent was organised into again. Responds like POST /media/history/{id}/scrape and records a run. It responds with 400 when no file of the torrent is organised yet (organise it again first), and for an old version replaced by an upgrade.
GET, PUT and DELETE /subscriptions/{id}/episode-rules
The episode-number rules of a followed show: how the episode number in a torrent title maps to the TMDB episode. There is one rule per release group; an empty group applies to every group. mode is tmdb (the TMDB episode number), period_part (by issue and part; for example "issue 1, part 2" of a variety show is TMDB episode 2), date (by air date) or offset (TMDB episode = the number in the title + offset).
- GET: every rule, each with
group,mode,offset,cross_season,source(manual,aiorauto),noteandupdated_at; - PUT:
{"group": "XX", "mode": "offset", "offset": 1, "note": "why"}replaces the group's rule if it has one. Withcross_seasonset totruethe group keeps counting across seasons (for example episode 1 of season 2 released as S01E171): torrents labeled with an earlier season are counted as this season's episodes usingoffset, and those labeled with this season keep their normal numbering. It needs a negativeoffsetand responds with 400 when the follow is for season 1 or uses an episode group; it defaults tofalse, and other modes ignore it; - DELETE: the parameter
group(leave it out to delete the rule for every group); responds with 404 when there is no such rule.
All three respond with every rule after the change. After a rule changes, a search under the new rule runs soon.
POST /subscriptions/{id}/status
{"status": "paused"} pauses and {"status": "active"} resumes; a resumed subscription searches again soon. The response is the updated subscription.
POST /subscriptions/{id}/search
Searches once now and responds with {"message": "explanation"}. A paused subscription responds with 400.
DELETE /subscriptions/{id}
Deletes the subscription and responds with {"ok": true}. Torrents in the downloader and files in the media library stay where they are.
GET /explore
| Parameter | Description |
|---|---|
kind | Required, movie or tv |
list | trending (the default), popular, or search (searches for q) |
q | The search words for list=search, up to 100 characters |
page | Starting at 1; trending and popular go up to 20 pages, search has one page |
The response has items, page and total_pages. Each item has id (the TMDB ID), media_type, title, original_title, year, overview, poster_path, vote_average, in_library, subscribed and subscription_id.
GET /images/tmdb/{size}/{file}
A TMDB image: file is poster_path without its leading /, and size is one of the poster sizes w92, w154, w185, w342, w500 and w780 (originals aren't offered, they can be several MB). pt-tools fetches it with the image address and proxy set under Media recognition and responds with the image and a one-day cache header, so clients never contact TMDB directly. Fetching images doesn't need a TMDB API key. It responds with 404 when TMDB has no such image, and with 502 (upstream) when the image can't be fetched. pt-tools fetches at most 4 images at a time; a request that waits longer than 10 seconds gets 503 (busy, with Retry-After).
AI assistant
These endpoints match the web page AI assistant; see AI assistant. Its settings (which model, the API key) can only be changed on the web, not here. Conversations are kept per caller: each token and each paired device sees only the conversations it created, and a signed-in web session sees the web conversations. Chatting needs only Read; when the model wants to change something, only a caller with Operate can confirm it (for a Read-only caller the model does not get those tools). Times are RFC 3339 strings.
GET /assistant/status
Responds with enabled (turned on, with an endpoint and a model configured), model, can_confirm (whether the caller can confirm actions) and chatops. It never contains the API key or the endpoint. On a host without these endpoints, features in GET /meta has no assistant.
GET /assistant/conversations
The caller's own conversations, most recently updated first, at most 100. Each has id, title, entry (where it was created: web, app or chatops), running, created_at and updated_at.
POST /assistant/conversations
{"title": "…", "message": "…"}, both optional; with message you can also give model and effort (as when sending a message). Creating only a conversation responds with 201; with message it also sends that message and responds with 202, where run has the run's run_id and the stored user message. If the AI assistant is not enabled it responds with 409 (assistant_disabled) and leaves no empty conversation behind.
GET /assistant/conversations/{id}
The conversation's own fields, plus:
messages: the latest 200 messages, oldest first. Each hasid,run_id,role(user,assistant,toolornotice),contentandcreated_at; assistant messages carrytool_calls(id,name,arguments,write) and, when the model returned its reasoning,reasoning(redacted); tool results carrytool_name,tool_call_idandis_error. User and assistant messages carry themodelandeffortof that turn (absent: the model from the settings, no effort given); user messages sent on the web with attachments haveattachments(id,name,kind(imageortext),mime,size; the contents are not available through the App API). Anoticeis pt-tools' own note (stopped, failed, step limit reached, the model does not take the reasoning effort, earlier messages were compacted into a summary).confirmations: pending actions withid,run_id,tool_call_id,tool,summary(one readable sentence),arguments,status(pending,approved,deniedorexpired),decided_by,decided_at,expires_atandcreated_at, plus the write tool's preview:changes(each item'slabel,beforeandafter;secretis true for secrets, which never show their value) andimpact(the possible impact). Match them to the calls in the messages byrun_idandtool_call_id.run_id,partialandpartial_reasoning: the run in progress and the answer and reasoning of its current step so far;last_seq: read events from here.usage: context usage,context(about how many tokens the next request carries),estimated(estimated from the text),window(the context window),window_source(setting,provider,tableordefault),auto_compact,compact_percent,inputandoutput(the input and output tokens the provider reported for this conversation) andcompacted(it was compacted). See Context and compaction.
POST /assistant/conversations/{id}/messages
{"text": "…"}, up to 4000 characters. Optional: model (the model for this turn, no spaces, at most 128 characters; the model from the settings when absent) and effort (none, minimal, low, medium, high or xhigh, sent to the model service as reasoning_effort; none when absent). When the model service rejects the request because of the effort, pt-tools retries once without it and adds a notice to the conversation. Responds with 202, the run's run_id and the stored user message. If the conversation is already answering it responds with 409 (busy). The App API takes no attachments (they can only be sent on the web).
POST /assistant/conversations/{id}/cancel
Stops the answer in progress and responds with {"ok": true}; does nothing when nothing is running. An action waiting for confirmation is voided and does not run.
GET /assistant/conversations/{id}/events
Long polling: after is the last sequence number you read (last_seq from the conversation, or last from the previous page), and wait is how many seconds to wait when there are no events (default and maximum 25). Responds with events, reset, last and running. When reset is true, events in between were lost (or pt-tools restarted): read the conversation again and continue from its last_seq.
Every event has seq, type and at, and depending on its type:
type | Contents |
|---|---|
run_started | run_id |
delta | text: a piece of the answer; with replace true, the whole answer so far |
message | message: a stored message (fields as in the conversation) |
tool_started | tool: the tool call that started |
confirmation | confirmation: a new pending action, or its decision |
run_finished | status (done, canceled or failed), with error on failure |
These are the only types. The web event stream also carries reasoning deltas (reasoning), usage (usage) and compaction starting (compacting); the App API leaves them out (installed older apps do not know the types). last still moves past them; the reasoning is in the message's reasoning once the answer is stored, and the usage is in the conversation's usage.
POST /assistant/confirmations/{id}
{"approve": true} confirms, {"approve": false} denies. Needs Operate. Responds with the decided action; one that already has a decision (decided elsewhere first, timed out or voided) gets 409 (decided). Confirming and denying are recorded in the audit log; the executed action gets its own entry with the channel AI assistant and the user token:<token id> or device:<device id>.
Message templates
These endpoints match ChatOps → Message templates (消息模板) on the web; the syntax is described in Message templates. A template applies to every channel and changes every notification and reply sent after it is saved, so saving and restoring the default need Operate, and only callers with Operate get the template source; changes made by tokens and devices are recorded in the audit log. Anything that looks like a credential is masked in the sample values, the built-in text and preview results. On a host without these endpoints, features in GET /meta has no templates.
GET /templates
Responds with groups, common_vars and events:
groups: the event groups.keyisnotify(notifications),reply(ChatOps command replies) orassistant(AI assistant replies), with anameand adesc.common_vars: the variables every event has. A variable has akey, atype(string,int,float,boolorlist), adescand asample(the sample value written as text); a list has no sample, and the fields of each item are initem.events: one entry per event withtype,group,name,desc,no_title(body only),vars,sample_titleandsample_text(what is sent when nothing is changed),titleandtext(the current templates; an empty one uses the built-in text; only callers with Operate get them, a read-only caller gets them empty and can tell fromcustomizedwhether there is one),customizedandupdated_at(when it was customized, as a Unix timestamp in seconds).
POST /templates/preview
{"type": "rss.matched", "title": "…", "text": "…"} renders the template with the event's sample data and saves nothing. Responds with {"title": "…", "text": "…"} (title is empty for a body-only event). A template that is not right gets 400 (invalid_argument) with a message naming the line and the problem; an unknown event gets 404.
PUT /templates/{type}
{"title": "…", "text": "…"} is checked the same way as a preview before it is saved and gets 400 when it is not right; leaving both empty restores the default. A title for a body-only event also gets 400. Responds with the event as saved (the same fields as an entry of events).
DELETE /templates/{type}
Restores the built-in text and responds with {"ok": true}; an unknown event gets 404.
Configuration
These endpoints read and change pt-tools' configuration through the configuration gateway, the same one behind MCP's get_config and change_config and the AI assistant's configuration changes. A change goes to the endpoint the web settings use, so validation, encryption and hot reload are the same. All of them need Config (app:config); reading and previewing also need Read, saving needs Operate. A web login has every permission; paired devices have no Config and get 403.
Not available here: the login password, API tokens, remote access, the encryption key, backup and restore, the AI assistant's own settings (including voice input), ChatOps bindings and admins, and the qB-compatible entrance.
GET /config
The catalog: resources lists what can be read and changed, each with name, title, description, kind (object is one set of settings, list a collection), id_field (the list items' ID field), ops, fields (writable fields; config.<key> means every field starting with it), required (needed when adding), secrets (secret fields) and hints (field notes). It also has excluded (what cannot be changed here) and secret_placeholder (<已设置>).
GET /config/{resource}
The current values: resource and kind; item for objects, items and id_field for lists. The query parameter id returns one list item (404 when there is none). Field names are the web endpoints' ones; secrets read as <已设置> (set) or an empty string, and user info and query strings of addresses in other fields are masked too.
POST /config/{resource}/preview
{ "op": "update", "id": "2", "values": { "enabled": false } }op is set (objects), add, update or delete (lists; update and delete need id); values holds only the fields to change. Numbers and switches use the current types; numbers written as strings are converted to match the current value. A new value changes a secret, giving back <已设置> keeps it and an empty string clears it. Responds with resource, op, id, summary (one sentence), changes (each item's label, field, before, after and secret), impact and applied (false). Unknown fields, values equal to the current ones and missing required fields get 400 (invalid_argument) with the writable fields in message; an unknown resource or ID gets 404.
POST /config/{resource}/changes
The same body as the preview. The change is worked out again from the current state (changes made elsewhere after the preview are taken into account) and saved; the response is like the preview with applied true, item as it is now (absent after a deletion) and a new item's ID in id. When the saving endpoint refuses, its reason comes back as it is: 400 for validation, 409 (conflict) for a conflict, 503 when the service is not running. Saves by tokens and devices are recorded in the audit log with the resource, operation, ID and the changed field names, not their values.
Mobile editors and statistics export
The features returned by GET /meta include mobile_editors, brush_manage and stats_export; period-based brush earnings (GET /brush/stats) are brush_stats; the subscription draft and trial search (see Follow assistant below) are subscription_assist; a downloader's categories and tags (GET /downloaders/{id}/labels) are downloader_labels; deleting a torrent completely is torrent_purge; what has been organised into a library (GET /media/libraries/{id}/items) is media_library. Clients prompt for an upgrade when a required feature is absent rather than falling back to session-only endpoints. The API compatibility level remains 1.
| Method | Path | Permission | Purpose |
|---|---|---|---|
| GET | /mobile/options | Read | IDs and names for enabled sites, downloaders (enabled says whether one is enabled; disabled ones are listed too), the downloaders' preset save folders (directories), quality profiles and libraries; errors reports failed sources |
| GET | /subscriptions/draft | Read | Read a title before creating a subscription: how many seasons, how many episodes the season has, which media library it would go into, whether it is already subscribed |
| POST | /subscriptions/search/preview | Read | Trial search: search once with an unsaved form; nothing is pushed or stored |
| GET | /brush/tasks/{id} | Read | Safe brush editor configuration |
| POST | /brush/tasks/preview | Read | Preview a ConfigChange, restricted to brush tasks |
| POST | /brush/tasks | Write | Create a brush task |
| PUT | /brush/tasks/{id} | Write | Update a brush task |
| DELETE | /brush/tasks/{id} | Write | Delete a brush task; the torrents it leaves behind are handed over to auto-delete |
| POST | /brush/tasks/{id}/status | Write | Enable or disable with {"enabled": true} or false |
| GET | /brush/tasks/{id}/runs | Read | Paginated run records |
| GET | /stats/aggregated | Read | Aggregated site statistics using the web statistics fields and billed download semantics |
| GET | /stats/summary?range=today | Read | Period deltas; range accepts today, 7d and 30d |
Run records use limit (default 20, maximum 100) and offset, returning items and total.
Brush create and update bodies use the web brush configuration fields, including the run windows run_windows and run_window_mode, the pause dates pause_dates, what happens to unfinished torrents while adding is paused off_hours_incomplete, and the low-yield rule groups low_yield_rules (see the brush API); leaving them out of an update keeps the current values. These endpoints do not grant general app:config access, site credential management or device administration. Writes use the existing App API audit chain. Subscription creation, editing and details also support include_keywords and exclude_keywords, with the same title matching semantics as the web UI.
Follow assistant
These two endpoints exist when features from GET /meta include subscription_assist; both need Read only.
GET /subscriptions/draft?media_type=tv&tmdb_id=1399&season=0 reads a title before creating a subscription and changes nothing. season applies to series only; 0 or absent means the latest season. The response has media_type, tmdb_id, season (for a series, the season that would actually be followed), seasons (how many seasons), total_episodes (episodes in the season), title, original_title, year, poster_path, anime, auto_library_id (the library Choose by type would organise into; 0 when no library can be used) and subscription_id (the existing subscription for the season or film; 0 when there is none). It responds with 404 when TMDB does not have the title or the season.
POST /subscriptions/search/preview searches once with an unsaved form, like Trial search in the web subscribe dialog; it is read-only and pushes nothing. The request:
| Field | Description |
|---|---|
media_type, tmdb_id | Required |
season | The series season; 0 or absent means the latest season |
profile_id | The form's quality profile; 0 or absent means the default profile in the settings (as after saving) |
sites | Only search these sites; all enabled sites when absent. Sites that are not enabled are not searched and go into errors |
include_keywords, exclude_keywords | The form's title includes and excludes as typed, written as for creating a subscription, at most 1024 bytes each |
include_unmatched | Also return torrents that do not match the title (at most 50) |
Aliases, episode-number rules and the episode group still come from the season's existing subscription, or from TMDB when there is none. The site search waits at most 25 seconds (including the TMDB reads before it); sites that have not answered by then go into errors with timed_out set, and the sites that did answer produce results as usual. Site search results are cached for 10 minutes, so trying again after changing only the title includes, excludes or the quality profile hits the cache; a run with a failing site is not cached.
The response: item (the title; a series also has seasons and total_episodes), subscription (the season's existing subscription: id, status and the locked version lock; absent when there is none), profile (the profile used for scoring; id 0 means there is no quality profile and releases are compared by resolution and source), keywords (the search words), episodes (each episode: number, state, and site while downloading) or movie (the film's state), groups (the same release from several sites in one group: the parsed meta, the verdict score with every reason it is rejected, the episodes span covers, covers the episodes it can fill, downloading, in_library, blocked, and members with each site's torrent: title, subtitle, size, seeders, discount, H&R, whether it is blocked and its own verdict), total, blocked_count, unmatched_count and unmatched (the torrents that do not match, with the reason), errors and duration_ms. The response contains no torrent links, download URLs or info hashes.
While a trial search from the same token or device is still running, another one gets 409 (busy); all callers together can run two at a time, and when both are taken it waits 2 seconds and then responds with 503 (busy) and Retry-After. When the client cancels the request (a remote-access cancel or a dropped connection), the trial search ends at once.