API methods

class qbittorrent.client.Client(url)[source]

class to interact with qBittorrent WEB API

add_trackers(infohash, trackers)[source]

Add trackers to a torrent.

Parameters:
  • infohash – INFO HASH of torrent.
  • trackers – Trackers.

:note %0A (aka LF newline) between trackers. Ampersand in tracker urls MUST be escaped.

alternative_speed_status

Get Alternative speed limits. (1/0)

api_version

Get WEB API version.

create_category(category)[source]

Create a new category :param category: category to create

decrease_priority(infohash_list)[source]

Decrease priority of torrents.

Parameters:infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
delete(infohash_list)[source]

Delete torrents. Does not remove files.

Parameters:infohash_list – Single or list() of infohashes.
delete_all()[source]

Delete all torrents. Does not remove files.

delete_all_permanently()[source]

Permanently delete torrents.

delete_permanently(infohash_list)[source]

Permanently delete torrents. Removes files.

Parameters:infohash_list – Single or list() of infohashes.
download_from_file(file_buffer, **kwargs)[source]

Download torrent using a file.

Parameters:
  • file_buffer – Single file() buffer or list of.
  • save_path – Path to download the torrent.
  • label – Label of the torrent(s).
Returns:

Empty JSON data.

Download torrent using a link.

Parameters:
  • link – URL Link or list of.
  • savepath – Path to download the torrent.
  • category – Label or Category of the torrent(s).
Returns:

Empty JSON data.

force_start(infohash_list, value)[source]

Force start selected torrents.

Parameters:
  • infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
  • value – Force start value (bool)
get_alternative_speed_status()[source]

Get Alternative speed limits. (1/0)

get_default_save_path()[source]

Get default save path.

get_global_download_limit()[source]

Get global download speed limit.

get_global_upload_limit()[source]

Get global upload speed limit.

get_log(**params)[source]

Returns a list of log entries matching the supplied params.

Parameters:
  • normal – Include normal messages (default: true).
  • info – Include info messages (default: true).
  • warning – Include warning messages (default: true).
  • critical – Include critical messages (default: true).
  • last_known_id – Exclude messages with “message id” <= last_known_id (default: -1).
Returns:

list().

For example: qb.get_log(normal=’true’, info=’true’)

get_torrent(infohash)[source]

Get details of the torrent.

Parameters:infohash – INFO HASH of the torrent.
get_torrent_download_limit(infohash_list)[source]

Get download speed limit of the supplied torrents.

Parameters:infohash_list – Single or list() of infohashes.
get_torrent_files(infohash)[source]

Get list of files for the torrent.

Parameters:infohash – INFO HASH of the torrent.
get_torrent_piece_hashes(infohash)[source]

Get list of all hashes (in order) of a specific torrent.

Parameters:infohash – INFO HASH of the torrent.
Returns:array of hashes (strings).
get_torrent_piece_states(infohash)[source]

Get list of all pieces (in order) of a specific torrent.

Parameters:infohash – INFO HASH of the torrent.
Returns:array of states (integers).
get_torrent_trackers(infohash)[source]

Get trackers for the torrent.

Parameters:infohash – INFO HASH of the torrent.
get_torrent_upload_limit(infohash_list)[source]

Get upoload speed limit of the supplied torrents.

Parameters:infohash_list – Single or list() of infohashes.
get_torrent_webseeds(infohash)[source]

Get webseeds for the torrent.

Parameters:infohash – INFO HASH of the torrent.
global_download_limit

Get global download speed limit.

global_transfer_info
Returns:dict{} of the global transfer info of qBittorrent.
global_upload_limit

Get global upload speed limit.

increase_priority(infohash_list)[source]

Increase priority of torrents.

Parameters:infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
login(username='admin', password='admin')[source]

Method to authenticate the qBittorrent Client.

Declares a class attribute named session which stores the authenticated session if the login is correct. Else, shows the login error.

Parameters:
  • username – Username.
  • password – Password.
Returns:

Response to login request to the API.

logout()[source]

Logout the current session.

pause(infohash)[source]

Pause a torrent.

Parameters:infohash – INFO HASH of torrent.
pause_all()[source]

Pause all torrents.

pause_multiple(infohash_list)[source]

Pause multiple torrents.

Parameters:infohash_list – Single or list() of infohashes.
preferences

Get the current qBittorrent preferences. Can also be used to assign individual preferences. For setting multiple preferences at once, see set_preferences method.

Note: Even if this is a property, to fetch the current preferences dict, you are required to call it like a bound method.

Wrong:

qb.preferences

Right:

qb.preferences()
qbittorrent_version

Get qBittorrent version.

reannounce(infohash_list)[source]

Recheck all torrents.

Parameters:infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
recheck(infohash_list)[source]

Recheck torrents.

Parameters:infohash_list – Single or list() of infohashes.
recheck_all()[source]

Recheck all torrents.

remove_category(categories)[source]

Remove categories

param categories:
 can contain multiple cateogies separated by

(%0A urlencoded).

resume(infohash)[source]

Resume a paused torrent.

Parameters:infohash – INFO HASH of torrent.
resume_all()[source]

Resume all torrents.

resume_multiple(infohash_list)[source]

Resume multiple paused torrents.

Parameters:infohash_list – Single or list() of infohashes.
set_automatic_torrent_management(infohash_list, enable='false')[source]

Set the category on multiple torrents.

Parameters:
  • infohash_list – Single or list() of infohashes.
  • enable – is a boolean, affects the torrents listed in infohash_list, default is ‘false’
set_category(infohash_list, category)[source]

Set the category on multiple torrents.

The category must exist before using set_category. As of v2.1.0,the API returns a 409 Client Error for any valid category name that doesn’t already exist.

Parameters:
  • infohash_list – Single or list() of infohashes.
  • category – If category is set to empty string ‘’,

the torrent(s) specified is/are removed from all categories.

set_file_priority(infohash, file_id, priority)[source]

Set file of a torrent to a supplied priority level.

Parameters:
  • infohash – INFO HASH of torrent.
  • file_id – ID of the file to set priority.
  • priority – Priority level of the file.

:note priority 4 is no priority set

set_global_download_limit(limit)[source]

Set global download speed limit.

Parameters:limit – Speed limit in bytes.
set_global_upload_limit(limit)[source]

Set global upload speed limit.

Parameters:limit – Speed limit in bytes.
set_max_priority(infohash_list)[source]

Set torrents to maximum priority level.

Parameters:infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
set_min_priority(infohash_list)[source]

Set torrents to minimum priority level.

Parameters:infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
set_preferences(**kwargs)[source]

Set preferences of qBittorrent. Read all possible preferences @ https://git.io/fx2Y9

Parameters:kwargs – set preferences in kwargs form.
set_super_seeding(infohash_list, value)[source]

Set super seeding for selected torrents.

Parameters:
  • infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
  • value – Force start value (bool)
set_torrent_download_limit(infohash_list, limit)[source]

Set download speed limit of the supplied torrents.

Parameters:
  • infohash_list – Single or list() of infohashes.
  • limit – Speed limit in bytes.
set_torrent_location(infohash_list, location)[source]

Set the location for the torrent

Parameters:
  • infohash – INFO HASH of torrent.
  • location – /mnt/nfs/media.
set_torrent_name(infohash, name)[source]

Set the name for the torrent

Parameters:
  • infohash – INFO HASH of torrent.
  • name – Whatever_name_you_want.
set_torrent_upload_limit(infohash_list, limit)[source]

Set upload speed limit of the supplied torrents.

Parameters:
  • infohash_list – Single or list() of infohashes.
  • limit – Speed limit in bytes.
shutdown()[source]

Shutdown qBittorrent.

sync_main_data(rid=0)[source]

Sync the torrents main data by supplied LAST RESPONSE ID. Read more @ https://git.io/fxgB8

Parameters:rid – Response ID of last request.
sync_peers_data(infohash, rid=0)[source]

Sync the torrent peers data by supplied LAST RESPONSE ID. Read more @ https://git.io/fxgBg

Parameters:
  • infohash – INFO HASH of torrent.
  • rid – Response ID of last request.
toggle_alternative_speed()[source]

Toggle alternative speed limits.

toggle_first_last_piece_priority(infohash_list)[source]

Toggle first/last piece priority of supplied torrents.

Parameters:infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
toggle_sequential_download(infohash_list)[source]

Toggle sequential download in supplied torrents.

Parameters:infohash_list – Single or list() of infohashes; pass ‘all’ for all torrents.
torrents(**filters)[source]

Returns a list of torrents matching the supplied filters.

Parameters:
  • filter – Current status of the torrents.
  • category – Fetch all torrents with the supplied label.
  • sort – Sort torrents by.
  • reverse – Enable reverse sorting.
  • limit – Limit the number of torrents returned.
  • offset – Set offset (if less than 0, offset from end).
Returns:

list() of torrent with matching filter.

For example: qb.torrents(filter=’downloading’, sort=’ratio’).

exception qbittorrent.client.LoginRequired[source]