Package: qbittorrent-api
qBittorrent Web API ClientPython client implementation for qBittorrent Web APICurrently supports qBittorrentv4.6.3(Web API v2.9.3) released on January 14, 2024.User Guide and API Reference available onRead the Docs.FeaturesThe entire qBittorrentWeb APIis implemented.qBittorrent version checking for an endpoint's existence/features is automatically handled.If the authentication cookie expires, a new one is automatically requested in line with any API call.InstallationInstall via pip fromPyPIpython-mpipinstallqbittorrent-apiGetting Startedimportqbittorrentapi# instantiate a Client using the appropriate WebUI configurationconn_info=dict(host="localhost",port=8080,username="admin",password="adminadmin",)qbt_client=qbittorrentapi.Client(**conn_info)# the Client will automatically acquire/maintain a logged-in state# in line with any request. therefore, this is not strictly necessary;# however, you may want to test the provided login credentials.try:qbt_client.auth_log_in()exceptqbittorrentapi.LoginFailedase: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.auth_log_out()# or use a context manager:withqbittorrentapi.Client(**conn_info)asqbt_client:ifqbt_client.torrents_add(urls="...")!="Ok.":raiseException("Failed to add torrent.")# display qBittorrent infoprint(f"qBittorrent:{qbt_client.app.version}")print(f"qBittorrent Web API:{qbt_client.app.web_api_version}")fork,vinqbt_client.app.build_info.items():print(f"{k}:{v}")# retrieve and show all torrentsfortorrentinqbt_client.torrents_info():print(f"{torrent.hash[-6:]}:{torrent.name}({torrent.state})")# pause all torrentsqbt_client.torrents.pause.all()Change Logv2024.2.59 (25 feb 2024)Allow added RSS feeds without a name/path to default to the name in the feed (#423)Advertise support for Python 3.13 (#349)v2024.1.58 (16 jan 2024)Advertise support for qBittorrent v4.6.3v2023.11.57 (27 nov 2023)Advertise support for qBittorrent v4.6.2v2023.11.56 (20 nov 2023)Advertise support for qBittorrent v4.6.1Add support fortorrents/count(#366)v2023.11.55 (6 nov 2023)Remove Python 2 platform tag from published wheel (#369)v2023.10.54 (22 oct 2023)Advertise support for qBittorrent v4.6.0Dropped support for legacy Python versions; Python 3.8+ is supported (#333)Refactored typing from stub files in to source (#345)Dropped support for API method argumentshashandhashes; usetorrent_hashandtorrent_hashes, respectively (#345)For example, replaceclient.torrents_info(hashes="...")withclient.torrents_info(torrent_hashes="...")v2023.9.53 (7 sept 2023)Advertise support for Python 3.12Advertise support for qBittorrent v4.5.5Addinactive_seeding_time_limitfortorrents/setShareLimits(#271)Implementapp/networkInterfaceListandapp/networkInterfaceAddressList(#272)v2023.7.52 (13 jul 2023)Ensure the wheel is uploaded with the release to PyPIv2023.7.51 (13 jul 2023)ConvertAPINamesandTorrentStatustoStrEnumandTrackerStatustoIntEnum(#267)v2023.6.50 (19 jun 2023)Advertise support for qBittorrent v4.5.4v2023.6.49 (9 jun 2023)TheClientis no longer binded toLists (#230)This does not affect normal operation but allows for slicing, adding, and copyingListsv2023.5.48 (29 may 2023)Advertise support for qBittorrent v4.5.3v2023.4.47 (19 apr 2023)Clientcan now be used as a context managerv2023.4.46 (14 apr 2023)Fix building docs after implementingsrc-layoutv2023.4.45 (11 apr 2023)Add theTrackerStatusEnum to identify tracker statuses fromtorrents/trackersv2023.3.44 (09 mar 2023)Add support for torrent status filtersseeding,moving,errored, andcheckingv2023.2.43 (27 feb 2023)Advertise support for qBittorrent v4.5.2v2023.2.42 (13 feb 2023)Advertise support for qBittorrent v4.5.1v2023.2.41 (8 feb 2023)Remove dependence on qBittorrent authentication cookie being namedSIDMinor typing fixesv2022.11.40 (27 nov 2022)Support qBittorrent v4.5.0 releaseAdd support fortorrents/exportImplement newtransfer/setSpeedLimitsModein place of existingtransfer/toggleSpeedLimitsModeAdd support forstopConditionintorrents/addUpdate typing to be complete, accurate, and shipped with the packagev2022.10.39 (26 oct 2022)Advertise support for Python 3.11v2022.8.38 (31 aug 2022)Advertise support for qBittorrent v4.4.5v2022.8.37 (24 aug 2022)Advertise support for qBittorrent v4.4.4v2022.8.36 (15 aug 2022)Comply with enforced HTTP method requirements from qBittorrentv2022.8.35 (13 aug 2022)RemovePYTHON_prefix for configuration environment variablesv2022.8.34 (11 aug 2022)Addsetuptoolsas an explicit dependency forpkg_resources.parse_version()v2022.7.33 (27 jul 2022)Reorder class hierarchy to allow independent MixIn useClean up typing annotationsOptimize Dictionary and List initializationsRename Alias decorator to alias for better conformityv2022.5.32 (30 may 2022)Implement pre-commit checksAdvertise support for qBittorrent v4.4.3.1v2022.5.31 (24 may 2022)Advertise support for qBittorrent v4.4.3Revamp GitHub CIReorgRequestfor some more clarity (hopefully)v2022.4.30 (3 apr 2022)Stop advertising support for Python 3.6 (EOL 12/2021)Publish to PyPI using API token and cleanup GitHub Action scriptsv2022.3.29 (25 mar 2022)Advertise support for qBittorrent v4.4.2v2022.2.28 (17 feb 2022)Advertise support for qBittorrent v4.4.1qBittorrent reverted the category dictionary keysavePathback tosave_pathv2022.1.27 (9 jan 2022)Support for qBittorrent v4.4.0torrents/inforesults can now be filtered by a torrent tagAdded new torrent state "Forced Metadata Downloading"Support per-torrent/per-category "download folder"v2021.12.26 (11 dec 2021)Stop sendingOriginandRefererheaders (Fixes #63)v2021.12.25 (10 dec 2021)Close files that are opened and sent to Requests when adding torrents from filesEnable warnings for tests and explicitly close Requests Sessions to prevent (mostly spurious) ResourceWarningsv2021.12.24 (3 dec 2021)Add Type Hints for all public and private functions, methods, and variablesSupport HTTP timeouts as well as arbitrary Requests configurationsv2021.8.23 (28 aug 2021)Advertise support for qBittorrent v4.3.8Drop support for Python 3.5v2021.5.22 (12 may 2021)Support for qBittorrent v4.3.5torrents/filesincludesindexfor each file;indexofficially replacesidbutidwill still be populatedv2021.5.21 (1 may 2021)Allow users to force a specific communications scheme withFORCE_SCHEME_FROM_HOST(fixes #54)v2021.4.20 (11 apr 2021)Add support for ratio limit and seeding time limit when adding torrentsv2021.4.19 (8 apr 2021)Update license in setup to match gpl->mit license change on GitHubv2021.3.18 (13 mar 2021)ReplaceTorrentStates.FORCE_DOWNLOAD='forceDL'withTorrentStates.FORCED_DOWNLOAD='forcedDL'v2021.2.17 (7 feb 2021)Generally refactorrequests.pyso it's better and easier to readPersist a Requests Session between API calls instead of always creating a new one...small perf benefitMove auth endpoints back to a dedicated moduleSinceattrdictis apparently going to break in Python 3.10 and it is no longer maintained, I've vendored a modified version (fixes #45)Createdhandle_hashesdecorator to hide the cruft of continuing to support hash and hashes argumentsv2021.1.16 (26 jan 2021)Support qBittorrent v4.3.3 and Web API v2.7 (...again)Newtorrents/renameFileandtorrents/renameFolderendpointsRetrieve app api version when needed instead of cachingStop verifying and removing individual parameters when they aren't supportedv2020.12.15 (27 dec 2020)Support qBittorrent v4.3.2 and Web API v2.7torrents/addsupports adding torrents with tags viatagsparameterapp/preferencessupports toggling internationalized domain name (IDN) support viaidn_support_enabledBREAKING CHANGE: fortorrents/add,is_root_folder(orroot_folder) is superseded bycontent_layoutFortorrents/delete,delete_filesnow defaults toFalseinstead of required being explicitly passedv2020.12.14 (6 dec 2020)Add support for non-standard API endpoint paths (Fixes #37)Allows users to leverage this client when qBittorrent is configured behind a reverse proxyFor instance, if the Web API is being exposed at "http://localhost/qbt/", then users can instantiate viaClient(host='localhost/qbt')and all API endpoint paths will be prefixed with "/qbt"Additionally, the scheme (i.e. http or https) from the user will now be respected as the first choice for which scheme is used to communicate with qBittorrentHowever, users still don't need to even specify a scheme; it'll be automatically determined on the first connection to qBittorrentNeither of these should be breaking changes, but if you're instantiating with an incorrect scheme or an irrelevant path, you may need to prevent doing that nowv2020.11.13 (29 nov 2020)Support qBittorrent v4.3.1 and Web API v2.6.1Path of torrent content now available viacontent_pathfromtorrents/infov2020.11.12 (16 nov 2020)Fix support for raw bytes fortorrent_filesintorrents_add()for Python 3 (Fixes #34)v2020.10.11 (29 oct 2020)Support qBittorrent v4.3.0.1 and Web API v2.6Due to qBittorrent changes,search/categoriesno longer returns anything andrss/renameRuleworks againv2020.10.10 (7 oct 2020)Advertise support for Python 3.9v2020.9.9 (12 sept 2020)Only requestenum34for Python 2v2020.8.8 (14 aug 2020)Support adding torrents from raw torrent files as bytes or file handles (Fixes #23)IntroduceTorrentStatesenum for qBittorrent list of torrent statesv2020.7.7 (26 jul 2020)Update tests and misc small fixesv2020.7.6 (25 jul 2020)Re-release of v2020.7.5v2020.7.5 (25 jul 2020)Add RTD documentationv2020.6.4 (9 jun 2020)Bug fix release. Reorganized code and classes to be more logicalStarted returning None from many methods that were returning Requests ResponsesContent-Length header is now explicitly sent as "0" for any POSTs without a bodyEndpoint input parametershashandhashesare renamed totorrent_hashandtorrent_hashes.hashandhashesremain supportedsearch_uninstall_pluginnow works. search_enable_plugin now supports multiple pluginsTorrent.download_limitnow only return the value instead of a dictionary.Torrent.upload_limitnow worksDrop advertising Python 2.6 and 3.4 support; add PyPy3 supportImplement test suite and CI that can test all supported qBittorrent versions on all pythonsv2020.5.3 (11 may 2020)Include currently supported qBittorrent version in README (Fixes #11)v2020.4.2 (25 apr 2020)Add support forrss/markAsReadandrss/matchingArticles. Added in v2.5.1 (Fixes #10)v2020.4.1 (25 apr 2020)Addstalled(),stalled_uploading(), andstalled_downloading()totorrents.infointeraction; added in Web API v2.4.1Implement torrent file renaming. Added in Web API v2.4.0 (Fixes #3)Since versioning was botched last release, implement calendar versioningList of files returned fromtorrents_files()now contains file ID inidv6.0.0 (22 apr 2020)Performance gains for responses with payloads...especially for large payloadsFixes #6. Adds support forSIMPLE_RESPONSESfor the entire client and individual methodsv0.5.2 (19 apr 2020)Fixes #8. Remove whitespace from in setPreferences requests for older qBittorrent versionsv0.5.1 (2 jan 2020)Add Python3.8 version for PyPIMove project from beta to stable for PyPIv0.5.0 (2 jan 2020)Make Web API URL derivation more robust...thereby allowing the client to actually work on Python3.8 (#5)Allow port to be discretely specified during Client instantiation (#4)Enhance request retry logic and expose retry configurationv0.4.2 (5 dec 2019)Improve organization and clarity of READMEBetter document exceptionsClarify torrent file handling exceptions better with proper exceptionsClean up the request wrapper exception handlingFix HTTP 404 handling to find and return problematic torrent hashesv0.4.1 (4 dec 2019)Round out support for tags with qBittorrent v4.2.0 releaseRemove upper-bound version requirements forrequestsandurllib3v0.4 (4 dec 2019)Support for qBittorrent v4.2.0 releaseAdd support forapp/buildInfoAdd support fortransfer/banPeersandtorrents/addPeersAdd support fortorrents/addTags,torrents/removeTags,torrents/tags,torrents/createTags, andtorrents/deleteTagsv0.3.3 (29 sept 2019)Fix useAutoTMM to autoTMM forclient.torrents_add()so auto torrent management worksAdd support to refresh RSS items introduced in qBittorrent v4.1.8v0.3.2 (28 jun 2019)Restore python 2 compatibilityAllow exceptions to be imported directly from package instead of only exceptions modulev0.3 (1 jun 2019)Finalized interaction layer interfacesv0.2 (13 may 2019)Introduced the "interaction layer" for transparent interaction with the qBittorrent APIv0.1 (7 may 2019)Complete implementation of qBittorrent WebUI API 2.2Each API endpoint is available via theClientclassAutomatic re-login is supported in the event of login expirationMIT LicenseCopyright (c) Russell MartinPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.