qbittorrent-api-v2
Version:
Wrapper around qBittorrent's Web API v2 to manage your torrents from Node. Documented and everything.
1,644 lines (583 loc) • 26 kB
Markdown
# Documentation *1.2.0*
See [qBittorrent's API documentation](https://github.com/qbittorrent/qBittorrent/wiki/Web-API-Documentation) for more info.
### Authentication
#### connect(host, username, password)
Login to qBittorrent
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| host | `string` | Host name of your qBittorrent instance | |
| username | `string` | Username used to access the WebUI | |
| password | `string` | Password used to access the WebUI | |
##### Returns
- `Promise<Object>` API methods
### Application
#### appVersion()
Get application version
##### Returns
- `Promise<string>` The response is a string with the application version, e.g. v4.1.3
#### apiVersion()
Get API version
##### Returns
- `Promise<string>` The response is a string with the WebAPI version, e.g. 2.0
#### buildInfo()
Get build info
##### Returns
- `Promise<BuildInfo>` Object containing build info
#### shutdown()
Shutdown application
##### Returns
- `Void`
#### preferences()
Get application preferences
##### Returns
- `Promise<Preferences>` Object containing the application's settings
#### defaultSavePath()
Get default save path
##### Returns
- `Promise<string>` Default save path, e.g. C:/Users/Dayman/Downloads
### Log
#### log(normal, info, warning, critical, lastKnownId)
Get log
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| normal | `boolean` | Include normal messages (default: `true`) | |
| info | `boolean` | Include info messages (default: `true`) | |
| warning | `boolean` | Include warning messages (default: `true`) | |
| critical | `boolean` | Include critical messages (default: `true`) | |
| lastKnownId | `number` | Exclude messages with "message id" <= `lastKnownId` (default: `-1`) | |
##### Returns
- `Promise<Array<Log>>` Logs
#### peerLog(lastKnownId)
Get peer log
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| lastKnownId | `number` | Exclude messages with "message id" <= `lastKnownId` (default: `-1`) | |
##### Returns
- `Promise<Array<PeerLog>>` Peer logs
### Sync
#### syncMainData(rid)
Get main data
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| rid | `number` | Response ID. If not provided, rid=0 will be assumed. If the given rid is different from the one of last server reply, `full_update` will be `true` | |
##### Returns
- `Promise<MainData>` Main data
#### syncPeersData(hash, rid)
Get torrent peers data
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | Torrent hash | |
| rid | `number` | Response ID. If not provided, rid=0 will be assumed. If the given rid is different from the one of last server reply, `full_update` will be `true` | |
##### Returns
- `Promise<PeerData>` Peer data
### Transfer info
#### transferInfo()
Get global transfer info
##### Returns
- `Promise<TransferInfo>` Transfer info
#### speedLimitsMode()
Get alternative speed limits state
##### Returns
- `Promise<number>` The response is 1 if alternative speed limits are enabled, 0 otherwise
#### toggleSpeedLimitsMode()
Toggle alternative speed limits
##### Returns
- `Void`
#### globalDownloadLimit()
Get global download limit
##### Returns
- `Promise<number>` Current global download speed limit in bytes/second; this value will be zero if no limit is applied
#### setGlobalDownloadLimit(limit)
Set global download limit
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| limit | `number` | The global download speed limit to set in bytes/second | |
##### Returns
- `Void`
#### globalUploadLimit()
Get global upload limit
##### Returns
- `Promise<number>` Current global upload speed limit in bytes/second; this value will be zero if no limit is applied
#### setGlobalUploadLimit(limit)
Set global upload limit
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| limit | `number` | The global upload speed limit to set in bytes/second | |
##### Returns
- `Void`
#### banPeers(peers)
Ban peers
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| peers | `string` | The peer to ban, or multiple peers separated by a pipe `|`. Each peer is a colon-separated `host:port` | |
##### Returns
- `Void`
### Torrent management
#### torrents(filter, category, sort, reverse, limit, offset, hashes)
Get torrent list
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| filter | `string` | Filter torrent list | |
| category | `string` | Get torrents with the given category (empty string means "without category"; null parameter means "any category") | |
| sort | `string` | Sort torrents by given key | |
| reverse | `boolean` | Enable reverse sorting | |
| limit | `number` | Limit the number of torrents returned | |
| offset | `number` | Set offset (if less than 0, offset from end) | |
| hashes | `string` | Filter by hashes. Can contain multiple hashes separated by | | |
##### Returns
- `Promise<Array<Torrent>>` Torrents
#### properties(hash)
Get torrent generic properties
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent you want to get the generic properties of | |
##### Returns
- `Promise<TorrentInfo>` Torrent properties
#### trackers(hash)
Get torrent trackers
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent you want to get the trackers of | |
##### Returns
- `Promise<Array<Tracker>>` Torrent trackers
#### webseeds(hash)
Get torrent webseeds
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent you want to get the webseeds of | |
##### Returns
- `Promise<Array<Webseed>>` Torrent webseeds
#### files(hash)
Get torrent contents
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent you want to get the contents of | |
##### Returns
- `Promise<Array<Content>>` Torrent contents
#### pieceStates(hash)
Get torrent pieces' states
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent you want to get the pieces' states of | |
##### Returns
- `Promise<Array<number>>` States (integers) of all pieces (in order) of the torrent
#### pieceHashes(hash)
Get torrent pieces' hashes
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent you want to get the pieces' hashes of | |
##### Returns
- `Promise<Array<string>>` Hashes (strings) of all pieces (in order) of the torrent
#### pauseTorrents(hashes)
Pause one or several torrents
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to pause. It can contain multiple hashes separated by |, to pause multiple torrents, or set to 'all', to pause all torrents | |
##### Returns
- `Void`
#### resumeTorrents(hashes)
Resume one or several torrents
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to resume. It can contain multiple hashes separated by |, to resume multiple torrents, or set to 'all', to resume all torrents | |
##### Returns
- `Void`
#### deleteTorrents(hashes, deleteFile)
Delete one or several torrents
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to delete. It can contain multiple hashes separated by |, to delete multiple torrents, or set to 'all', to delete all torrents | |
| deleteFile | `boolean` | If set to `true`, the downloaded data will also be deleted, otherwise has no effect | |
##### Returns
- `Void`
#### recheckTorrents(hashes)
Recheck one or several torrents
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to recheck. It can contain multiple hashes separated by |, to recheck multiple torrents, or set to 'all', to recheck all torrents | |
##### Returns
- `Void`
#### reannounceTorrents(hashes)
Reannounce one or several torrents
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to reannounce. It can contain multiple hashes separated by |, to reannounce multiple torrents, or set to 'all', to reannounce all torrents | |
##### Returns
- `Void`
#### editTrackers(hash, origUrl, newUrl)
Edit trackers
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent | |
| origUrl | `string` | The tracker URL you want to edit | |
| newUrl | `string` | The new URL to replace the `origUrl` | |
##### Returns
- `Void`
#### removeTrackers(hash, url)
Remove trackers
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent | |
| url | `string` | URLs to remove, separated by `|` | |
##### Returns
- `Void`
#### addPeers(hashes, peers)
Add peers
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hash of the torrent, or multiple hashes separated by a pipe `|` | |
| peers | `string` | The peer to add, or multiple peers separated by a pipe `|`. Each peer is a colon-separated `host:port` | |
##### Returns
- `Void`
#### addTrackers(hash, urls)
Add trackers to torrent
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent | |
| urls | `string` | URLs of the trackers, separated by a newline `\n` | |
##### Returns
- `Void`
#### increasePriority(hashes)
Increase torrent priority
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to increase the priority of. It can contain multiple hashes separated by `|`, to increase the priority of multiple torrents, or set to 'all', to increase the priority of all torrents | |
##### Returns
- `Void`
#### decreasePriority(hashes)
Decrease torrent priority
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to decrease the priority of. It can contain multiple hashes separated by `|`, to decrease the priority of multiple torrents, or set to 'all', to decrease the priority of all torrents | |
##### Returns
- `Void`
#### maxPriority(hashes)
Maximal torrent priority
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set to the maximum priority. It can contain multiple hashes separated by `|`, to set multiple torrents to the maximum priority, or set to 'all', to set all torrents to the maximum priority | |
##### Returns
- `Void`
#### minPriority(hashes)
Minimal torrent priority
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set to the minimum priority. It can contain multiple hashes separated by `|`, to set multiple torrents to the minimum priority, or set to 'all', to set all torrents to the minimum priority | |
##### Returns
- `Void`
#### setFilePriority(hash, id, priority)
Set file priority
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent | |
| id | `string` | File ids, separated by `|` | |
| priority | `number` | File priority to set | |
##### Returns
- `Void`
#### downloadLimit(hashes)
Get torrent download limit
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents. It can contain multiple hashes separated by `|` or set to 'all' | |
##### Returns
- `Void`
#### setDownloadLimit(hashes, limit)
Set torrent download limit
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set the download limit. It can contain multiple hashes separated by `|`, to set the download limit of multiple torrents, or set to 'all', to set all torrents the download limit | |
| limit | `string` | Download speed limit in bytes per second you want to set | |
##### Returns
- `Void`
#### setShareLimit(hashes, ratioLimit, seedingTimeLimit)
Set torrent share limit
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set the share limit. It can contain multiple hashes separated by `|`, to set the share limit of multiple torrents, or set to 'all', to set all torrents the share limit | |
| ratioLimit | `string` | Max ratio the torrent should be seeded until. `-2` means the global limit should be used, `-1` means no limit | |
| seedingTimeLimit | `string` | Max amount of time the torrent should be seeded. `-2` means the global limit should be used, `-1` means no limit | |
##### Returns
- `Void`
#### uploadLimit(hashes)
Get torrent upload limit
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents. It can contain multiple hashes separated by `|` or set to 'all' | |
##### Returns
- `Void`
#### setUploadLimit(hashes, limit)
Set torrent upload limit
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set the upload limit. It can contain multiple hashes separated by `|`, to set the upload limit of multiple torrents, or set to 'all', to set all torrents the upload limit | |
| limit | `string` | Upload speed limit in bytes per second you want to set | |
##### Returns
- `Void`
#### setLocation(hashes, location)
Set torrent location
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set the location. It can contain multiple hashes separated by `|`, to set the location of multiple torrents, or set to 'all', to set all torrents the location | |
| location | `string` | Location to download the torrent to. If the location doesn't exist, the torrent's location is unchanged | |
##### Returns
- `Void`
#### rename(hash, name)
Set torrent name
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent | |
| name | `string` | New torrent name | |
##### Returns
- `Void`
#### setCategory(hashes, category)
Set torrent category
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set the category. It can contain multiple hashes separated by `|`, to set the category of multiple torrents, or set to 'all', to set the category of all torrents | |
| category | `string` | The torrent category you want to set | |
##### Returns
- `Void`
#### categories()
Get all categories
##### Returns
- `Promise<Categories>` Categories in JSON format
#### createCategory(category, savePath)
Add new category
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| category | `string` | The category you want to create | |
| savePath | `string` | Save path of the category | |
##### Returns
- `Void`
#### editCategory(category, savePath)
Edit category
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| category | `string` | The category you want to edit | |
| savePath | `string` | Save path of the category | |
##### Returns
- `Void`
#### removeCategories(categories)
Remove categories
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| categories | `string` | Category you want to remove. It can contain multiple cateogies separated by a newline `\n` | |
##### Returns
- `Void`
#### addTags(hashes, tags)
Add torrent tags
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to add tags to. It can contain multiple hashes separated by `|`, to add tags to multiple torrents, or set to 'all', to add the tags of all torrents | |
| tags | `string` | The list of tags you want to add to passed torrents | |
##### Returns
- `Void`
#### removeTags(hashes, tags)
Remove torrent tags
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to remove tags to. It can contain multiple hashes separated by `|`, to remove tags to multiple torrents, or set to 'all', to remove the tags of all torrents | |
| tags | `string` | Category you want to remove. It can contain multiple cateogies separated by a newline `\n` | |
##### Returns
- `Void`
#### tags()
Get all tags
##### Returns
- `Promise<Array<string>>` Tags
#### createTags(tags)
Create tags
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| tags | `string` | List of tags you want to create. Can contain multiple tags separated by `,` | |
##### Returns
- `Void`
#### deleteTags(tags)
Delete tags
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| tags | `string` | List of tags you want to delete. Can contain multiple tags separated by `,` | |
##### Returns
- `Void`
#### setAutoManagement(hashes, enable)
Set automatic torrent management
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set automatic torrent management. It can contain multiple hashes separated by `|`, to set automatic torrent management of multiple torrents, or set to 'all', to set automatic torrent management of all torrents | |
| enable | `boolean` | Enable automatic torrent management or not for the torrents listed in `hashes` | |
##### Returns
- `Void`
#### toggleSequentialDownload(hashes)
Toggle sequential download
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to toggle sequential download for. It can contain multiple hashes separated by `|`, to toggle sequential download for multiple torrents, or set to 'all', to toggle sequential download for all torrents | |
##### Returns
- `Void`
#### toggleFirstLastPiecePrio(hashes)
Set first/last piece priority
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to toggle the first/last piece priority for. It can contain multiple hashes separated by `|`, to toggle the first/last piece priority for multiple torrents, or set to 'all', to toggle the first/last piece priority for all torrents | |
##### Returns
- `Void`
#### setForceStart(hashes, value)
Set force start
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set force start. It can contain multiple hashes separated by `|`, to set force start of multiple torrents, or set to 'all', to set force start of all torrents | |
| value | `boolean` | Enable force start or not for the torrents listed in `hashes` | |
##### Returns
- `Void`
#### setSuperSeeding(hashes, value)
Set super seeding
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hashes | `string` | The hashes of the torrents you want to set super seeding. It can contain multiple hashes separated by `|`, to set super seeding of multiple torrents, or set to 'all', to set super seeding of all torrents | |
| value | `boolean` | Enable super seeding or not for the torrents listed in `hashes` | |
##### Returns
- `Void`
#### renameFile(hash, id, name)
Rename file
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| hash | `string` | The hash of the torrent | |
| id | `number` | The id of the file to rename | |
| name | `string` | The new name to use for the file | |
##### Returns
- `Void`
### Search
#### startSearch(pattern, plugins, category)
Start search
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| pattern | `string` | Pattern to search for (e.g. "Ubuntu 18.04") | |
| plugins | `string` | Plugins to use for searching (e.g. "legittorrents"). Supports multiple plugins separated by `|`. Also supports 'all' and 'enabled' | |
| category | `string` | Categories to limit your search to (e.g. "legittorrents"). Available categories depend on the specified plugins. Also supports 'all' | |
##### Returns
- `Promise<SearchJob>` Search ID as JSON
#### stopSearch(id)
Stop search
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| id | `number` | ID of the search job | |
##### Returns
- `Void`
#### searchStatus([id])
Get search status
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| id | `number` | ID of the search job. If not specified, all search jobs are returned | *Optional* |
##### Returns
- `Promise<Array<SearchStatus>>` Status of the search jobs
#### searchResults(id[, limit, offset])
Get search results
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| id | `number` | ID of the search job | |
| limit | `number` | Max number of results to return. 0 or negative means no limit | *Optional* |
| offset | `number` | Result to start at. A negative number means count backwards (e.g. -2 returns the 2 most recent results) | *Optional* |
##### Returns
- `Promise<SearchResults>` Search results
#### deleteSearch(id)
Delete search
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| id | `number` | ID of the search job | |
##### Returns
- `Void`
#### searchCategories([pluginName])
Get search categories
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| pluginName | `string` | Name of the plugin (e.g. "legittorrents"). Also supports 'all' and 'enabled' | *Optional* |
##### Returns
- `Promise<Array<string>>` List of categories
#### searchPlugins()
Get search plugins
##### Returns
- `Promise<Array<SearchPlugin>>` List of plugins
#### installPlugin(sources)
Install search plugin
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| sources | `string` | Url or file path of the plugin to install. Supports multiple sources separated by `|` | |
##### Returns
- `Void`
#### uninstallPlugin(names)
Uninstall search plugin
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| names | `string` | Name of the plugin to uninstall (e.g. "legittorrents"). Supports multiple names separated by `|` | |
##### Returns
- `Void`
#### enablePlugin(names, enable)
Enable search plugin
##### Parameters
| Name | Type | Description | |
| ---- | ---- | ----------- | -------- |
| names | `string` | Name of the plugin to enable/disable (e.g. "legittorrents"). Supports multiple names separated by `|` | |
| enable | `boolean` | Whether the plugins should be enabled | |
##### Returns
- `Void`
#### updatePlugins()
Update search plugins
##### Returns
- `Void`