Client#

class Client(host='', 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)#

Bases: LogAPIMixIn, SyncAPIMixIn, TransferAPIMixIn, TorrentsAPIMixIn, TorrentCreatorAPIMixIn, RSSAPIMixIn, SearchAPIMixIn

Initialize API for qBittorrent client.

Host must be specified. Username and password can be specified at login. A call to auth_log_in() is not explicitly required if username and password are provided during Client construction.

Usage:
>>> from qbittorrentapi import Client
>>> client = Client(host='localhost:8080', username='admin', password='adminadmin')
>>> torrents = client.torrents_info()
Parameters:
  • host (str) – hostname for qBittorrent Web API, [http[s]://]localhost[:8080][/path]

  • port (str | int | None) – port number for qBittorrent Web API (ignored if host contains a port)

  • username (str | None) – username for qBittorrent Web API

  • password (str | None) – password for qBittorrent Web API

  • SIMPLE_RESPONSES (bool) – By default, complex objects are returned from some endpoints. These objects will allow for accessing responses’ items as attributes and include methods for contextually relevant actions. This comes at the cost of performance. Generally, this cost isn’t large; however, some endpoints, such as torrents_files() method, may need to convert a large payload. Set this to True to return the simple JSON back. Alternatively, set this to True only for an individual method call. For instance, when requesting the files for a torrent: client.torrents_files(torrent_hash='...', SIMPLE_RESPONSES=True)

  • VERIFY_WEBUI_CERTIFICATE (bool) – Set to False to skip verify certificate for HTTPS connections; for instance, if the connection is using a self-signed certificate. Not setting this to False for self-signed certs will cause a APIConnectionError exception to be raised.

  • EXTRA_HEADERS (Optional[Mapping[str, str]]) – Dictionary of HTTP Headers to include in all requests made to qBittorrent.

  • REQUESTS_ARGS (Optional[Mapping[str, Any]]) – Dictionary of configuration for Requests package: https://requests.readthedocs.io/en/latest/api/#requests.request

  • FORCE_SCHEME_FROM_HOST (bool) – If a scheme (i.e. http or https) is specified in host, it will be used regardless of whether qBittorrent is configured for HTTP or HTTPS communication. Normally, this client will attempt to determine which scheme qBittorrent is actually listening on… but this can cause problems in rare cases. Defaults False.

  • RAISE_NOTIMPLEMENTEDERROR_FOR_UNIMPLEMENTED_API_ENDPOINTS (bool) – Some Endpoints may not be implemented in older versions of qBittorrent. Setting this to True will raise a NotImplementedError instead of just returning``None``.

  • RAISE_ERROR_FOR_UNSUPPORTED_QBITTORRENT_VERSIONS (bool) – raise the UnsupportedQbittorrentVersion exception if the connected version of qBittorrent is not fully supported by this client. Defaults False.

  • DISABLE_LOGGING_DEBUG_OUTPUT (bool) – Turn off debug output from logging for this package as well as Requests & urllib3.