Torrents#
- class TorrentsAPIMixIn(host=None, port=None, username=None, password=None, EXTRA_HEADERS=None, REQUESTS_ARGS=None, VERIFY_WEBUI_CERTIFICATE=True, FORCE_SCHEME_FROM_HOST=False, RAISE_NOTIMPLEMENTEDERROR_FOR_UNIMPLEMENTED_API_ENDPOINTS=False, RAISE_ERROR_FOR_UNSUPPORTED_QBITTORRENT_VERSIONS=False, VERBOSE_RESPONSE_LOGGING=False, SIMPLE_RESPONSES=False, DISABLE_LOGGING_DEBUG_OUTPUT=False) None #
Bases:
AppAPIMixIn
Implementation of all Torrents API methods.
- Usage:
>>> from qbittorrentapi import Client >>> client = Client(host="localhost:8080", username="admin", password="adminadmin") >>> client.torrents_add(urls="...") >>> client.torrents_reannounce()
- torrents_add(urls=None, torrent_files=None, save_path=None, cookie=None, category=None, is_skip_checking=None, is_paused=None, is_root_folder=None, rename=None, upload_limit=None, download_limit=None, use_auto_torrent_management=None, is_sequential_download=None, is_first_last_piece_priority=None, tags=None, content_layout=None, ratio_limit=None, seeding_time_limit=None, download_path=None, use_download_path=None, stop_condition=None, add_to_top_of_queue=None, inactive_seeding_time_limit=None, share_limit_action=None, ssl_certificate=None, ssl_private_key=None, ssl_dh_params=None, is_stopped=None, **kwargs) str #
Add one or more torrents by URLs and/or torrent files.
Returns
Ok.
for success andFails.
for failure.- Raises:
UnsupportedMediaType415Error – if file is not a valid torrent file
TorrentFileNotFoundError – if a torrent file doesn’t exist
TorrentFilePermissionError – if read permission is denied to torrent file
- Parameters:
urls (
Optional
[Iterable
[str
]]) – single instance or an iterable of URLs (http://
,https://
,magnet:
,bc://bt/
)torrent_files (
Optional
[TypeVar
(TorrentFilesT
,bytes
,str
,IO
[bytes
],Mapping
[str
,Union
[bytes
,str
,IO
[bytes
]]],Iterable
[Union
[bytes
,str
,IO
[bytes
]]])]) –several options are available to send torrent files to qBittorrent:
single instance of bytes: useful if torrent file already read from disk or downloaded from internet.
single instance of file handle to torrent file: use
open(<filepath>, 'rb')
to open the torrent file.single instance of a filepath to torrent file: e.g.
/home/user/torrent_filename.torrent
an iterable of the single instances above to send more than one torrent file
dictionary with key/value pairs of torrent name and single instance of above object
Note: The torrent name in a dictionary is useful to identify which torrent file errored. qBittorrent provides back that name in the error text. If a torrent name is not provided, then the name of the file will be used. And in the case of bytes (or if filename cannot be determined), the value ‘torrent__n’ will be used.
is_paused (
bool
|None
) – Adds torrent in stopped state; alias foris_stopped
is_root_folder (
bool
|None
) –True
orFalse
to create root folder (superseded by content_layout with v4.3.2)upload_limit (
str
|int
|None
) – upload limit in bytes/seconddownload_limit (
str
|int
|None
) – download limit in bytes/seconduse_auto_torrent_management (
bool
|None
) –True
orFalse
to use automatic torrent managementis_sequential_download (
bool
|None
) –True
orFalse
for sequential downloadis_first_last_piece_priority (
bool
|None
) –True
orFalse
for first and last piece download prioritytags (
Optional
[Iterable
[str
]]) – tag(s) to assign to torrent(s) (added in Web API v2.6.2)content_layout (
Optional
[Literal
['Original'
,'Subfolder'
,'NoSubFolder'
]]) –Original
,Subfolder
, orNoSubfolder
to control filesystem structure for content (added in Web API v2.7)ratio_limit (
str
|float
|None
) – share limit as ratio of upload amt over download amt; e.g. 0.5 or 2.0 (added in Web API v2.8.1)seeding_time_limit (
str
|int
|None
) – number of minutes to seed torrent (added in Web API v2.8.1)download_path (
str
|None
) – location to download torrent content before moving tosave_path
(added in Web API v2.8.4)use_download_path (
bool
|None
) –True
orFalse
whetherdownload_path
should be used…defaults toTrue
ifdownload_path
is specified (added in Web API v2.8.4)stop_condition (
Optional
[Literal
['MetadataReceived'
,'FilesChecked'
]]) –MetadataReceived
orFilesChecked
to stop the torrent when started automatically (added in Web API v2.8.15)add_to_top_of_queue (
bool
|None
) – puts torrent at top to the queue (added in Web API v2.8.19)inactive_seeding_time_limit (
str
|int
|None
) – limit for seeding while inactive (added in Web API v2.9.2)share_limit_action (
Optional
[Literal
['Stop'
,'Remove'
,'RemoveWithContent'
,'EnableSuperSeeding'
]]) – override default action when share limit is reached (added in Web API v2.10.4)ssl_certificate (
str
|None
) – peer certificate (in PEM format) (added in Web API v2.10.4)ssl_private_key (
str
|None
) – peer private key (added in Web API v2.10.4)ssl_dh_params (
str
|None
) – Diffie-Hellman parameters (added in Web API v2.10.4)is_stopped (
bool
|None
) – Adds torrent in stopped state; alias foris_paused
(added in Web API v2.11.0)
- Return type:
- torrents_add_peers(peers=None, torrent_hashes=None, **kwargs) TorrentsAddPeersDictionary #
Add one or more peers to one or more torrents.
This method was introduced with qBittorrent v4.4.0 (Web API v2.3.0).
- Raises:
InvalidRequest400Error – for invalid peers
- Parameters:
- Return type:
- torrents_add_tags(tags=None, torrent_hashes=None, **kwargs) None #
Add one or more tags to one or more torrents.
Note: Tags that do not exist will be created on-the-fly.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- torrents_bottom_priority(torrent_hashes=None, **kwargs) None #
Set torrent as lowest priority. Torrent Queuing must be enabled.
- torrents_categories(**kwargs) TorrentCategoriesDictionary #
Retrieve all category definitions.
This method was introduced with qBittorrent v4.1.4 (Web API v2.1.1).
Note:
torrents/categories
is not available until v2.1.0- Return type:
- torrents_create_category(name=None, save_path=None, download_path=None, enable_download_path=None, **kwargs) None #
Create a new torrent category.
- Raises:
Conflict409Error – if category name is not valid or unable to create
- Parameters:
- Return type:
- torrents_create_tags(tags=None, **kwargs) None #
Create one or more tags.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- torrents_decrease_priority(torrent_hashes=None, **kwargs) None #
Decrease the priority of a torrent. Torrent Queuing must be enabled.
- torrents_delete(delete_files=False, torrent_hashes=None, **kwargs) None #
Remove a torrent from qBittorrent and optionally delete its files.
- torrents_delete_tags(tags=None, **kwargs) None #
Delete one or more tags.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- torrents_download_limit(torrent_hashes=None, **kwargs) TorrentLimitsDictionary #
Retrieve the download limit for one or more torrents.
- Return type:
- torrents_edit_category(name=None, save_path=None, download_path=None, enable_download_path=None, **kwargs) None #
Edit an existing category.
This method was introduced with qBittorrent v4.1.3 (Web API v2.1.0).
- Raises:
Conflict409Error – if category name is not valid or unable to create
- Parameters:
- Return type:
- torrents_edit_tracker(torrent_hash=None, original_url=None, new_url=None, **kwargs) None #
Replace a torrent’s tracker with a different one.
This method was introduced with qBittorrent v4.1.4 (Web API v2.2.0).
- Raises:
- Parameters:
- Return type:
- torrents_export(torrent_hash=None, **kwargs) bytes #
Export a .torrent file for the torrent.
This method was introduced with qBittorrent v4.5.0 (Web API v2.8.14).
- Raises:
NotFound404Error – torrent not found
Conflict409Error – unable to export .torrent file
- Parameters:
- Return type:
- torrents_file_priority(torrent_hash=None, file_ids=None, priority=None, **kwargs) None #
Set priority for one or more files.
- Raises:
InvalidRequest400Error – if priority is invalid or at least one file ID is not an integer
Conflict409Error – if torrent metadata has not finished downloading or at least one file was not found
- Parameters:
- Return type:
- torrents_files(torrent_hash=None, **kwargs) TorrentFilesList #
Retrieve individual torrent’s files.
- Raises:
- Parameters:
- Return type:
- torrents_increase_priority(torrent_hashes=None, **kwargs) None #
Increase the priority of a torrent. Torrent Queuing must be enabled.
- torrents_info(status_filter=None, category=None, sort=None, reverse=None, limit=None, offset=None, torrent_hashes=None, tag=None, **kwargs) TorrentInfoList #
Retrieves list of info for torrents.
- Parameters:
status_filter (
Optional
[Literal
['all'
,'downloading'
,'seeding'
,'completed'
,'paused'
,'stopped'
,'active'
,'inactive'
,'resumed'
,'running'
,'stalled'
,'stalled_uploading'
,'stalled_downloading'
,'checking'
,'moving'
,'errored'
]]) –Filter list by torrent status:
Original options:
all
,downloading
,seeding
,completed
,paused
,active
,inactive
,resumed
,errored
Added in Web API v2.4.1:
stalled
,stalled_uploading
, andstalled_downloading
Added in Web API v2.8.4:
checking
Added in Web API v2.8.18:
moving
Added in Web API v2.11.0:
stopped
(replacedpaused
),running
(replacedresumed
)
offset (
str
|int
|None
) – Start of list (if < 0, offset from end of list)torrent_hashes (
Optional
[Iterable
[str
]]) – Filter list by hash (separate multiple hashes with a ‘|’) (added in Web API v2.0.1)tag (
str
|None
) – Filter list by tag (empty string means “untagged”; no “tag” parameter means “any tag”; added in Web API v2.8.3)
- Return type:
- torrents_piece_hashes(torrent_hash=None, **kwargs) TorrentPieceInfoList #
Retrieve individual torrent’s pieces’ hashes.
- Raises:
- Parameters:
- Return type:
- torrents_piece_states(torrent_hash=None, **kwargs) TorrentPieceInfoList #
Retrieve individual torrent’s pieces’ states.
- Raises:
- Parameters:
- Return type:
- torrents_properties(torrent_hash=None, **kwargs) TorrentPropertiesDictionary #
Retrieve individual torrent’s properties.
- Raises:
- Parameters:
- Return type:
- torrents_reannounce(torrent_hashes=None, **kwargs) None #
Reannounce a torrent.
This method was introduced with qBittorrent v4.1.2 (Web API v2.0.2).
- torrents_remove_tags(tags=None, torrent_hashes=None, **kwargs) None #
Add one or more tags to one or more torrents.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- torrents_remove_trackers(torrent_hash=None, urls=None, **kwargs) None #
Remove trackers from a torrent.
This method was introduced with qBittorrent v4.1.4 (Web API v2.2.0).
- Raises:
- Parameters:
- Return type:
- torrents_rename_file(torrent_hash=None, file_id=None, new_file_name=None, old_path=None, new_path=None, **kwargs) None #
Rename a torrent file.
This method was introduced with qBittorrent v4.2.1 (Web API v2.4.0).
- Raises:
- Parameters:
- Return type:
- torrents_rename_folder(torrent_hash=None, old_path=None, new_path=None, **kwargs) None #
Rename a torrent folder.
This method was introduced with qBittorrent v4.3.2 (Web API v2.7).
- Raises:
- Parameters:
- Return type:
- torrents_set_auto_management(enable=None, torrent_hashes=None, **kwargs) None #
Enable or disable automatic torrent management for one or more torrents.
- torrents_set_category(category=None, torrent_hashes=None, **kwargs) None #
Set a category for one or more torrents.
- torrents_set_download_limit(limit=None, torrent_hashes=None, **kwargs) None #
Set the download limit for one or more torrents.
- torrents_set_download_path(download_path=None, torrent_hashes=None, **kwargs) None #
Set the Download Path for one or more torrents.
This method was introduced with qBittorrent v4.4.0 (Web API v2.8.4).
- Raises:
Forbidden403Error – cannot write to directory
Conflict409Error – cannot create directory
- Parameters:
- Return type:
- torrents_set_force_start(enable=None, torrent_hashes=None, **kwargs) None #
Force start one or more torrents.
- torrents_set_location(location=None, torrent_hashes=None, **kwargs) None #
Set location for torrents’ files.
- Raises:
Forbidden403Error – if the user doesn’t have permissions to write to the location (only before v4.5.2 - write check was removed.)
Conflict409Error – if the directory cannot be created at the location
- Parameters:
- Return type:
- torrents_set_save_path(save_path=None, torrent_hashes=None, **kwargs) None #
Set the Save Path for one or more torrents.
This method was introduced with qBittorrent v4.4.0 (Web API v2.8.4).
- Raises:
Forbidden403Error – cannot write to directory
Conflict409Error – cannot create directory
- Parameters:
- Return type:
Set share limits for one or more torrents.
This method was introduced with qBittorrent v4.1.1 (Web API v2.0.1).
- Parameters:
torrent_hashes (
Optional
[Iterable
[str
]]) – single torrent hash or list of torrent hashes. Orall
for all torrents.ratio_limit (
str
|int
|None
) – max ratio to seed a torrent. (-2 means use the global value and -1 is no limit)seeding_time_limit (
str
|int
|None
) – minutes (-2 means use the global value and -1 is no limit)inactive_seeding_time_limit (
str
|int
|None
) – minutes (-2 means use the global value and -1 is no limit) (added in Web API v2.9.2)
- Return type:
- torrents_set_super_seeding(enable=None, torrent_hashes=None, **kwargs) None #
Set one or more torrents as super seeding.
- torrents_set_upload_limit(limit=None, torrent_hashes=None, **kwargs) None #
Set the upload limit for one or more torrents.
- torrents_tags(**kwargs) TagList #
Retrieve all tag definitions.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- Return type:
- torrents_toggle_first_last_piece_priority(torrent_hashes=None, **kwargs) None #
Toggle priority of first/last piece downloading.
- torrents_toggle_sequential_download(torrent_hashes=None, **kwargs) None #
Toggle sequential download for one or more torrents.
- torrents_top_priority(torrent_hashes=None, **kwargs) None #
Set torrent as highest priority. Torrent Queuing must be enabled.
- torrents_trackers(torrent_hash=None, **kwargs) TrackersList #
Retrieve individual torrent’s trackers. Tracker status is defined in
TrackerStatus
.- Raises:
- Parameters:
- Return type:
- torrents_upload_limit(torrent_hashes=None, **kwargs) TorrentLimitsDictionary #
Retrieve the upload limit for one or more torrents.
- torrents_webseeds(torrent_hash=None, **kwargs) WebSeedsList #
Retrieve individual torrent’s web seeds.
- Raises:
- Parameters:
- Return type:
- class Torrents(client) None #
Allows interaction with the
Torrents
API endpoints.- Usage:
>>> from qbittorrentapi import Client >>> client = Client(host="localhost:8080", username="admin", password="adminadmin") >>> # these are all the same attributes that are available as named in the >>> # endpoints or the more pythonic names in Client (with or without 'torrents_' prepended) >>> torrent_list = client.torrents.info() >>> torrent_list_active = client.torrents.info.active() >>> torrent_list_active_partial = client.torrents.info.active(limit=100, offset=200) >>> torrent_list_downloading = client.torrents.info.downloading() >>> # torrent looping >>> for torrent in client.torrents.info.completed() >>> # all torrents endpoints with a 'hashes' parameters support all method to apply action to all torrents >>> client.torrents.stop.all() >>> client.torrents.start.all() >>> # or specify the individual hashes >>> client.torrents.downloadLimit(torrent_hashes=["...", "..."])
- add(urls=None, torrent_files=None, save_path=None, cookie=None, category=None, is_skip_checking=None, is_paused=None, is_root_folder=None, rename=None, upload_limit=None, download_limit=None, use_auto_torrent_management=None, is_sequential_download=None, is_first_last_piece_priority=None, tags=None, content_layout=None, ratio_limit=None, seeding_time_limit=None, download_path=None, use_download_path=None, stop_condition=None, add_to_top_of_queue=None, inactive_seeding_time_limit=None, share_limit_action=None, ssl_certificate=None, ssl_private_key=None, ssl_dh_params=None, is_stopped=None, **kwargs) str #
Add one or more torrents by URLs and/or torrent files.
Returns
Ok.
for success andFails.
for failure.- Raises:
UnsupportedMediaType415Error – if file is not a valid torrent file
TorrentFileNotFoundError – if a torrent file doesn’t exist
TorrentFilePermissionError – if read permission is denied to torrent file
- Parameters:
urls (
Optional
[Iterable
[str
]]) – single instance or an iterable of URLs (http://
,https://
,magnet:
,bc://bt/
)torrent_files (
Optional
[TypeVar
(TorrentFilesT
,bytes
,str
,IO
[bytes
],Mapping
[str
,Union
[bytes
,str
,IO
[bytes
]]],Iterable
[Union
[bytes
,str
,IO
[bytes
]]])]) –several options are available to send torrent files to qBittorrent:
single instance of bytes: useful if torrent file already read from disk or downloaded from internet.
single instance of file handle to torrent file: use
open(<filepath>, 'rb')
to open the torrent file.single instance of a filepath to torrent file: e.g.
/home/user/torrent_filename.torrent
an iterable of the single instances above to send more than one torrent file
dictionary with key/value pairs of torrent name and single instance of above object
Note: The torrent name in a dictionary is useful to identify which torrent file errored. qBittorrent provides back that name in the error text. If a torrent name is not provided, then the name of the file will be used. And in the case of bytes (or if filename cannot be determined), the value ‘torrent__n’ will be used.
is_paused (
bool
|None
) – Adds torrent in stopped state; alias foris_stopped
is_root_folder (
bool
|None
) –True
orFalse
to create root folder (superseded by content_layout with v4.3.2)upload_limit (
str
|int
|None
) – upload limit in bytes/seconddownload_limit (
str
|int
|None
) – download limit in bytes/seconduse_auto_torrent_management (
bool
|None
) –True
orFalse
to use automatic torrent managementis_sequential_download (
bool
|None
) –True
orFalse
for sequential downloadis_first_last_piece_priority (
bool
|None
) –True
orFalse
for first and last piece download prioritytags (
Optional
[Iterable
[str
]]) – tag(s) to assign to torrent(s) (added in Web API v2.6.2)content_layout (
Optional
[Literal
['Original'
,'Subfolder'
,'NoSubFolder'
]]) –Original
,Subfolder
, orNoSubfolder
to control filesystem structure for content (added in Web API v2.7)ratio_limit (
str
|float
|None
) – share limit as ratio of upload amt over download amt; e.g. 0.5 or 2.0 (added in Web API v2.8.1)seeding_time_limit (
str
|int
|None
) – number of minutes to seed torrent (added in Web API v2.8.1)download_path (
str
|None
) – location to download torrent content before moving tosave_path
(added in Web API v2.8.4)use_download_path (
bool
|None
) –True
orFalse
whetherdownload_path
should be used…defaults toTrue
ifdownload_path
is specified (added in Web API v2.8.4)stop_condition (
Optional
[Literal
['MetadataReceived'
,'FilesChecked'
]]) –MetadataReceived
orFilesChecked
to stop the torrent when started automatically (added in Web API v2.8.15)add_to_top_of_queue (
bool
|None
) – puts torrent at top to the queue (added in Web API v2.8.19)inactive_seeding_time_limit (
str
|int
|None
) – limit for seeding while inactive (added in Web API v2.9.2)share_limit_action (
Optional
[Literal
['Stop'
,'Remove'
,'RemoveWithContent'
,'EnableSuperSeeding'
]]) – override default action when share limit is reached (added in Web API v2.10.4)ssl_certificate (
str
|None
) – peer certificate (in PEM format) (added in Web API v2.10.4)ssl_private_key (
str
|None
) – peer private key (added in Web API v2.10.4)ssl_dh_params (
str
|None
) – Diffie-Hellman parameters (added in Web API v2.10.4)is_stopped (
bool
|None
) – Adds torrent in stopped state; alias foris_paused
(added in Web API v2.11.0)
- Return type:
- edit_tracker(torrent_hash=None, original_url=None, new_url=None, **kwargs) None #
Replace a torrent’s tracker with a different one.
This method was introduced with qBittorrent v4.1.4 (Web API v2.2.0).
- Raises:
- Parameters:
- Return type:
- export(torrent_hash=None, **kwargs) bytes #
Export a .torrent file for the torrent.
This method was introduced with qBittorrent v4.5.0 (Web API v2.8.14).
- Raises:
NotFound404Error – torrent not found
Conflict409Error – unable to export .torrent file
- Parameters:
- Return type:
- file_priority(torrent_hash=None, file_ids=None, priority=None, **kwargs) None #
Set priority for one or more files.
- Raises:
InvalidRequest400Error – if priority is invalid or at least one file ID is not an integer
Conflict409Error – if torrent metadata has not finished downloading or at least one file was not found
- Parameters:
- Return type:
- files(torrent_hash=None, **kwargs) TorrentFilesList #
Retrieve individual torrent’s files.
- Raises:
- Parameters:
- Return type:
- piece_hashes(torrent_hash=None, **kwargs) TorrentPieceInfoList #
Retrieve individual torrent’s pieces’ hashes.
- Raises:
- Parameters:
- Return type:
- piece_states(torrent_hash=None, **kwargs) TorrentPieceInfoList #
Retrieve individual torrent’s pieces’ states.
- Raises:
- Parameters:
- Return type:
- properties(torrent_hash=None, **kwargs) TorrentPropertiesDictionary #
Retrieve individual torrent’s properties.
- Raises:
- Parameters:
- Return type:
- remove_trackers(torrent_hash=None, urls=None, **kwargs) None #
Remove trackers from a torrent.
This method was introduced with qBittorrent v4.1.4 (Web API v2.2.0).
- Raises:
- Parameters:
- Return type:
- rename_file(torrent_hash=None, file_id=None, new_file_name=None, old_path=None, new_path=None, **kwargs) None #
Rename a torrent file.
This method was introduced with qBittorrent v4.2.1 (Web API v2.4.0).
- Raises:
- Parameters:
- Return type:
- rename_folder(torrent_hash=None, old_path=None, new_path=None, **kwargs) None #
Rename a torrent folder.
This method was introduced with qBittorrent v4.3.2 (Web API v2.7).
- Raises:
- Parameters:
- Return type:
- trackers(torrent_hash=None, **kwargs) TrackersList #
Retrieve individual torrent’s trackers. Tracker status is defined in
TrackerStatus
.- Raises:
- Parameters:
- Return type:
- webseeds(torrent_hash=None, **kwargs) WebSeedsList #
Retrieve individual torrent’s web seeds.
- Raises:
- Parameters:
- Return type:
- class TorrentDictionary(data, client) None #
Bases:
ClientCache
[TorrentsAPIMixIn
],ListEntry
Item in
TorrentInfoList
. Allows interaction with individual torrents via theTorrents
API endpoints.- Usage:
>>> from qbittorrentapi import Client >>> client = Client(host="localhost:8080", username="admin", password="adminadmin") >>> # these are all the same attributes that are available as named in the >>> # endpoints or the more pythonic names in Client (with or without 'transfer_' prepended) >>> torrent = client.torrents.info()[0] >>> torrent_hash = torrent.info.hash >>> # Attributes without inputs and a return value are properties >>> properties = torrent.properties >>> trackers = torrent.trackers >>> files = torrent.files >>> # Action methods >>> torrent.edit_tracker(original_url="...", new_url="...") >>> torrent.remove_trackers(urls="http://127.0.0.2/") >>> torrent.rename(new_torrent_name="...") >>> torrent.start() >>> torrent.stop() >>> torrent.recheck() >>> torrent.torrents_top_priority() >>> torrent.setLocation(location="/home/user/torrents/") >>> torrent.setCategory(category="video")
- add_tags(tags=None, torrent_hashes=None, **kwargs) None #
Add one or more tags to one or more torrents.
Note: Tags that do not exist will be created on-the-fly.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- bottom_priority(torrent_hashes=None, **kwargs) None #
Set torrent as lowest priority. Torrent Queuing must be enabled.
- decrease_priority(torrent_hashes=None, **kwargs) None #
Decrease the priority of a torrent. Torrent Queuing must be enabled.
- delete(delete_files=False, torrent_hashes=None, **kwargs) None #
Remove a torrent from qBittorrent and optionally delete its files.
- property download_limit: TorrentLimitsDictionary#
Retrieve the download limit for one or more torrents.
- edit_tracker(torrent_hash=None, original_url=None, new_url=None, **kwargs) None #
Replace a torrent’s tracker with a different one.
This method was introduced with qBittorrent v4.1.4 (Web API v2.2.0).
- Raises:
- Parameters:
- Return type:
- export(torrent_hash=None, **kwargs) bytes #
Export a .torrent file for the torrent.
This method was introduced with qBittorrent v4.5.0 (Web API v2.8.14).
- Raises:
NotFound404Error – torrent not found
Conflict409Error – unable to export .torrent file
- Parameters:
- Return type:
- file_priority(torrent_hash=None, file_ids=None, priority=None, **kwargs) None #
Set priority for one or more files.
- Raises:
InvalidRequest400Error – if priority is invalid or at least one file ID is not an integer
Conflict409Error – if torrent metadata has not finished downloading or at least one file was not found
- Parameters:
- Return type:
- property files: TorrentFilesList#
Retrieve individual torrent’s files.
- Raises:
- Parameters:
- increase_priority(torrent_hashes=None, **kwargs) None #
Increase the priority of a torrent. Torrent Queuing must be enabled.
- property info: TorrentDictionary#
Returns data from
torrents_info()
for the torrent.
- property piece_hashes: TorrentPieceInfoList#
Retrieve individual torrent’s pieces’ hashes.
- Raises:
- Parameters:
- property piece_states: TorrentPieceInfoList#
Retrieve individual torrent’s pieces’ states.
- Raises:
- Parameters:
- property properties: TorrentPropertiesDictionary#
Retrieve individual torrent’s properties.
- Raises:
- Parameters:
- reannounce(torrent_hashes=None, **kwargs) None #
Reannounce a torrent.
This method was introduced with qBittorrent v4.1.2 (Web API v2.0.2).
- remove_tags(tags=None, torrent_hashes=None, **kwargs) None #
Add one or more tags to one or more torrents.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- remove_trackers(torrent_hash=None, urls=None, **kwargs) None #
Remove trackers from a torrent.
This method was introduced with qBittorrent v4.1.4 (Web API v2.2.0).
- Raises:
- Parameters:
- Return type:
- rename_file(torrent_hash=None, file_id=None, new_file_name=None, old_path=None, new_path=None, **kwargs) None #
Rename a torrent file.
This method was introduced with qBittorrent v4.2.1 (Web API v2.4.0).
- Raises:
- Parameters:
- Return type:
- rename_folder(torrent_hash=None, old_path=None, new_path=None, **kwargs) None #
Rename a torrent folder.
This method was introduced with qBittorrent v4.3.2 (Web API v2.7).
- Raises:
- Parameters:
- Return type:
- set_auto_management(enable=None, torrent_hashes=None, **kwargs) None #
Enable or disable automatic torrent management for one or more torrents.
- set_category(category=None, torrent_hashes=None, **kwargs) None #
Set a category for one or more torrents.
- set_download_limit(limit=None, torrent_hashes=None, **kwargs) None #
Set the download limit for one or more torrents.
- set_download_path(download_path=None, torrent_hashes=None, **kwargs) None #
Set the Download Path for one or more torrents.
This method was introduced with qBittorrent v4.4.0 (Web API v2.8.4).
- Raises:
Forbidden403Error – cannot write to directory
Conflict409Error – cannot create directory
- Parameters:
- Return type:
- set_force_start(enable=None, torrent_hashes=None, **kwargs) None #
Force start one or more torrents.
- set_location(location=None, torrent_hashes=None, **kwargs) None #
Set location for torrents’ files.
- Raises:
Forbidden403Error – if the user doesn’t have permissions to write to the location (only before v4.5.2 - write check was removed.)
Conflict409Error – if the directory cannot be created at the location
- Parameters:
- Return type:
- set_save_path(save_path=None, torrent_hashes=None, **kwargs) None #
Set the Save Path for one or more torrents.
This method was introduced with qBittorrent v4.4.0 (Web API v2.8.4).
- Raises:
Forbidden403Error – cannot write to directory
Conflict409Error – cannot create directory
- Parameters:
- Return type:
Set share limits for one or more torrents.
This method was introduced with qBittorrent v4.1.1 (Web API v2.0.1).
- Parameters:
torrent_hashes (
Optional
[Iterable
[str
]]) – single torrent hash or list of torrent hashes. Orall
for all torrents.ratio_limit (
str
|int
|None
) – max ratio to seed a torrent. (-2 means use the global value and -1 is no limit)seeding_time_limit (
str
|int
|None
) – minutes (-2 means use the global value and -1 is no limit)inactive_seeding_time_limit (
str
|int
|None
) – minutes (-2 means use the global value and -1 is no limit) (added in Web API v2.9.2)
- Return type:
- set_super_seeding(enable=None, torrent_hashes=None, **kwargs) None #
Set one or more torrents as super seeding.
- set_upload_limit(limit=None, torrent_hashes=None, **kwargs) None #
Set the upload limit for one or more torrents.
- property state_enum: TorrentState#
Torrent state enum.
- toggle_first_last_piece_priority(torrent_hashes=None, **kwargs) None #
Toggle priority of first/last piece downloading.
- toggle_sequential_download(torrent_hashes=None, **kwargs) None #
Toggle sequential download for one or more torrents.
- top_priority(torrent_hashes=None, **kwargs) None #
Set torrent as highest priority. Torrent Queuing must be enabled.
- property trackers: TrackersList#
Retrieve individual torrent’s trackers. Tracker status is defined in
TrackerStatus
.- Raises:
- Parameters:
- property upload_limit: TorrentLimitsDictionary#
Retrieve the upload limit for one or more torrents.
- property webseeds: WebSeedsList#
Retrieve individual torrent’s web seeds.
- Raises:
- Parameters:
- class TorrentCategories(*args, client, **kwargs)#
Bases:
ClientCache
[TorrentsAPIMixIn
]Allows interaction with torrent categories within the
Torrents
API endpoints.- Usage:
>>> from qbittorrentapi import Client >>> client = Client(host="localhost:8080", username="admin", password="adminadmin") >>> # these are all the same attributes that are available as named in the >>> # endpoints or the more pythonic names in Client (with or without 'torrents_' prepended) >>> categories = client.torrent_categories.categories >>> # create or edit categories >>> client.torrent_categories.create_category(name="Video", save_path="/home/user/torrents/Video") >>> client.torrent_categories.edit_category(name="Video", save_path="/data/torrents/Video") >>> # edit or create new by assignment >>> client.torrent_categories.categories = dict(name="Video", save_path="/hone/user/") >>> # delete categories >>> client.torrent_categories.removeCategories(categories="Video") >>> client.torrent_categories.removeCategories(categories=["Audio", "ISOs"])
- property categories: TorrentCategoriesDictionary#
Retrieve all category definitions.
This method was introduced with qBittorrent v4.1.4 (Web API v2.1.1).
Note:
torrents/categories
is not available until v2.1.0
- create_category(name=None, save_path=None, download_path=None, enable_download_path=None, **kwargs) None #
Create a new torrent category.
- Raises:
Conflict409Error – if category name is not valid or unable to create
- Parameters:
- Return type:
- edit_category(name=None, save_path=None, download_path=None, enable_download_path=None, **kwargs) None #
Edit an existing category.
This method was introduced with qBittorrent v4.1.3 (Web API v2.1.0).
- Raises:
Conflict409Error – if category name is not valid or unable to create
- Parameters:
- Return type:
- class TorrentTags(*args, client, **kwargs)#
Bases:
ClientCache
[TorrentsAPIMixIn
]Allows interaction with torrent tags within the “Torrent” API endpoints.
- Usage:
>>> from qbittorrentapi import Client >>> client = Client(host="localhost:8080", username="admin", password="adminadmin") >>> tags = client.torrent_tags.tags >>> client.torrent_tags.tags = "tv show" # create category >>> client.torrent_tags.create_tags(tags=["tv show", "linux distro"]) >>> client.torrent_tags.delete_tags(tags="tv show")
- add_tags(tags=None, torrent_hashes=None, **kwargs) None #
Add one or more tags to one or more torrents.
Note: Tags that do not exist will be created on-the-fly.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- create_tags(tags=None, **kwargs) None #
Create one or more tags.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- delete_tags(tags=None, **kwargs) None #
Delete one or more tags.
This method was introduced with qBittorrent v4.2.0 (Web API v2.3.0).
- class TorrentPropertiesDictionary(data=None, **kwargs)#
Bases:
Dictionary
[Union
[None
,int
,str
,bool
,Sequence
[JsonValueT
],Mapping
[str
,JsonValueT
]]]Response to
torrents_properties()
- class TorrentLimitsDictionary(data=None, **kwargs)#
Bases:
Dictionary
[Union
[None
,int
,str
,bool
,Sequence
[JsonValueT
],Mapping
[str
,JsonValueT
]]]Response to
torrents_download_limit()
- class TorrentCategoriesDictionary(data=None, **kwargs)#
Bases:
Dictionary
[Union
[None
,int
,str
,bool
,Sequence
[JsonValueT
],Mapping
[str
,JsonValueT
]]]Response to
torrents_categories()
- class TorrentsAddPeersDictionary(data=None, **kwargs)#
Bases:
Dictionary
[Union
[None
,int
,str
,bool
,Sequence
[JsonValueT
],Mapping
[str
,JsonValueT
]]]Response to
torrents_add_peers()
- class TorrentFilesList(list_entries, client=None)#
Bases:
List
[TorrentFile
]Response to
torrents_files()
- class TorrentFile(data=None, **kwargs)#
Bases:
ListEntry
Item in
TorrentFilesList
- class WebSeedsList(list_entries, client=None)#
-
Response to
torrents_webseeds()
- class WebSeed(data=None, **kwargs)#
Bases:
ListEntry
Item in
WebSeedsList
- class TrackersList(list_entries, client=None)#
-
Response to
torrents_trackers()
- class Tracker(data=None, **kwargs)#
Bases:
ListEntry
Item in
TrackersList
- class TorrentInfoList(list_entries, client=None)#
Bases:
List
[TorrentDictionary]Response to
torrents_info()
Definition: https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#user-content-get-torrent-list
- class TorrentPieceInfoList(list_entries, client=None)#
Bases:
List
[TorrentPieceData
]Response to
torrents_piece_states()
andtorrents_piece_hashes()
- class TorrentPieceData(data=None, **kwargs)#
Bases:
ListEntry
Item in
TorrentPieceInfoList
- class TagList(list_entries, client=None)#
-
Response to
torrents_tags()