torrents_add ( urls = "." ) != "Ok." : raise Exception ( "Failed to add torrent." ) # display qBittorrent info print ( f "qBittorrent: )" ) # pause all torrents qbt_client. Client ( ** conn_info ) as qbt_client : if qbt_client. auth_log_out () # or use a context manager: with qbittorrentapi. LoginFailed as e : print ( e ) # if the Client will not be long-lived or many Clients may be created # in a relatively short amount of time, be sure to log out: qbt_client. therefore, this is not strictly necessary # however, you may want to test the provided login credentials. Client ( ** conn_info ) # the Client will automatically acquire/maintain a logged-in state # in line with any request. Getting Started import qbittorrentapi # instantiate a Client using the appropriate WebUI configuration conn_info = dict ( host = "localhost", port = 8080, username = "admin", password = "adminadmin", ) qbt_client = qbittorrentapi. Install via pip from PyPI python -m pip install qbittorrent-api
If the authentication cookie expires, a new one is automatically requested in line with any API call.
qBittorrent version checking for an endpoint's existence/features is automatically handled.
The entire qBittorrent Web API is implemented.
User Guide and API Reference available on Read the Docs. Python client implementation for qBittorrent Web APIĬurrently supports qBittorrent v4.5.2 (Web API v2.8.19) released on Feb 27, 2023.