Client¶
- class Client(host='', port=None, username=None, password=None, *, api_key=None, EXTRA_HEADERS=None, REQUESTS_ARGS=None, HTTPADAPTER_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,SearchAPIMixInInitialize 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]://]hostname[:port][/path]port (
str|int|None) – port number for qBittorrent Web API (ignored if host contains a port)api_key (
str|None) – API key for qBittorrent Web API (qBittorrent v5.2.0+); generated in the qBittorrent WebUI (qbt_...). When provided, it is used as an alternative tousername/password(and takes precedence over them): requests are authenticated via anAuthorization: Bearerheader and the cookie-based login/logout flow is skipped.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 astorrents_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 toFalseto skip verify certificate for HTTPS connections; for instance, if the connection is using a self-signed certificate. Not setting this toFalsefor self-signed certs will cause aAPIConnectionErrorexception to be raised.EXTRA_HEADERS (
Mapping[str,str] |None) – Dictionary of HTTP Headers to include in all requests made to qBittorrent.REQUESTS_ARGS (
Mapping[str,Any] |None) – Dictionary of configuration for each HTTP request made byrequests.request.HTTPADAPTER_ARGS (
Mapping[str,Any] |None) – Dictionary of configuration forHTTPAdapter.FORCE_SCHEME_FROM_HOST (
bool) – If a scheme (i.e.httporhttps) 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. DefaultsFalse.RAISE_NOTIMPLEMENTEDERROR_FOR_UNIMPLEMENTED_API_ENDPOINTS (
bool) – Some endpoints may not be implemented in older versions of qBittorrent. Setting this toTruewill raise aNotImplementedErrorinstead of just returningNone.RAISE_ERROR_FOR_UNSUPPORTED_QBITTORRENT_VERSIONS (
bool) – RaiseUnsupportedQbittorrentVersionif the connected version of qBittorrent is not fully supported by this client. DefaultsFalse.DISABLE_LOGGING_DEBUG_OUTPUT (
bool) – Turn off debug output from logging for this package as well asrequests&urllib3.