需先自行部署并开启 qBittorrent 的 WebUI,默认端口 8080;默认凭据为 admin/adminadmin,实际使用需替换;客户端长期存活或频繁创建时记得调用 auth_log_out 或使用 with 语句
qbittorrent-api
rmartin16MIT活跃维护用 Python 调用 qBittorrent Web API 的客户端库,方便脚本化地管理种子任务、查询下载状态和自动化操作。
Python client implementation for qBittorrent's Web API
python -m pip install qbittorrent-apiREADME 未说明;这是纯 Python 客户端库,本身无 GPU 或显存要求,只需能访问 qBittorrent WebUI 的网络环境
用 Python 调用 qBittorrent Web API 的客户端库,省去手写 HTTP 请求和版本兼容处理
用 Python 调用 qBittorrent Web API 的客户端库,方便脚本化地管理种子任务、查询下载状态和自动化操作。
核心能力
- 完整实现 qBittorrent Web API 全部端点
- 自动检测 qBittorrent 版本以匹配端点特性
- 认证 cookie 过期时随请求自动重新登录
- 支持上下文管理器自动登入登出
- 提供 torrents、app 等分类对象式调用接口
容易踩的坑
- v2026.10.1release-2026.10.1最新正式版2026-10-21 · 2026-10-21 05:49 UTC
What's Changed
Features
- feat: support qBittorrent v5.3.0 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/689
Chores
- build(deps): bump uv from 0.11.18 to 0.13.4 by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/687
- build(deps): bump certifi from 2026.5.20 to 2026.10.19 by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/688
Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.10.0...v2026.10.1
- v2026.10.0release-2026.10.02026-10-03 · 2026-10-03 16:20 UTC
查看更新说明
What's Changed
Features
- feat: add Web API v2.16.0 endpoints (qBittorrent v5.3.0) by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/659
- feat: add Web API v2.16.2 endpoints (qBittorrent v5.3.0beta1) by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/678
- feat: support qBittorrent v5.2.4 and v5.3.0rc1 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/686
Chores
- Bump pre-commit hook for mirrors-mypy from v2.3.0 to v2.3.1 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/677
- Bump the github-actions group with 2 updates by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/674
- Bump the uv group with 6 updates by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/675
- Bump pre-commit hook for ruff-pre-commit from v0.16.1 to v0.16.5 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/676
- Bump soupsieve from 2.8.4 to 2.9 by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/679
- Bump anyio from 4.13.0 to 4.14.2 by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/680
- Bump pre-commit hook for ruff-pre-commit from v0.16.5 to v0.16.9 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/683
- Bump the github-actions group with 3 updates by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/681
- Bump the uv group with 5 updates by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/682
- build(deps): bump virtualenv from 21.4.2 to 21.7.13 by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/685
CI
- refactor(tests): parametrize test_add_delete and fix dead assertions by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/662
- refactor(tests): derive an endpoint catalog and test the API surface from it by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/663
- docs(tests): explain how the test suite works by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/664
- refactor(tests): stop testing each camelCase alias over the network by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/665
- fix(tests): make webseed checks survive a busy qBittorrent by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/667
- refactor(tests): extend the catalog to interface spellings by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/666
- refactor(tests): remove the gate twins the catalog now covers by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/669
- refactor(tests): catalog torrent objects and drop the last gate twins by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/670
- refactor(tests): add eventually() and migrate test_search to it by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/671
- refactor(tests): finish the eventually() migration and delete check() by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/672
- test(tests): fail any test that leaves state behind in qBittorrent by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/673
Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.8.1...v2026.10.0
- v2026.8.1release-2026.8.12026-08-16 · 2026-08-16 20:30 UTC
查看更新说明
What's Changed
Features
- feat: add missing
torrents/addandtorrents/reannounceparameters by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/656 - feat: add endpoints shipped in qBittorrent v5.2.x by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/658
Fixes
- fix: accept and forward
**kwargson all API methods by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/655 - fix: send
seedModeforis_skip_checkingon Web API v2.16.0 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/654 - docs: correct version annotations by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/657
Chores
- Bump cryptography from 48.0.1 to 50.0.0 by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/652
- retire codeql by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/660
- remove xfail for previous python 3.15 issue by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/638
Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.8.0...v2026.8.1
- feat: add missing
- v2026.8.0release-2026.8.02026-08-01 · 2026-08-01 21:05 UTC
查看更新说明
What's Changed
Fixes
- fix: preserve cached client when slicing or copying List objects by @Sanjays2402 in https://github.com/rmartin16/qbittorrent-api/pull/644
CI
- ignore conflict409 on adding torrents in tests by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/640
- make CI tests resilient to qBittorrent's eventual consistency by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/643
Chores
- Bump the github-actions group with 4 updates by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/647
- Bump pre-commit hook for ruff-pre-commit from v0.15.20 to v0.16.1 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/649
- Bump pre-commit hook for mirrors-mypy from v2.1.0 to v2.3.0 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/650
- Bump the uv group with 7 updates by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/648
New Contributors
- @Sanjays2402 made their first contribution in https://github.com/rmartin16/qbittorrent-api/pull/644
Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.7.0...v2026.8.0
- v2026.7.0release-2026.7.02026-07-08 · 2026-07-08 00:54 UTC
查看更新说明
What's Changed
Fixes
- Advertise support for qBittorrent v5.2.3
- Accept float for ratio_limit in set_share_limits by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/637
Chores
- Bump the github-actions group with 4 updates by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/633
- Bump the uv group with 3 updates by @dependabot[bot] in https://github.com/rmartin16/qbittorrent-api/pull/634
- Bump pre-commit hook for ruff-pre-commit from v0.15.15 to v0.15.20 by @rmartin16 in https://github.com/rmartin16/qbittorrent-api/pull/635
Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.6.1...v2026.7.0
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
qBittorrent Web API Client
Python client implementation for qBittorrent Web API
Currently supports qBittorrent v5.3.0 (Web API v2.16.2) released on October 20, 2026.
User Guide and API Reference available on Read the Docs.
Features
- The entire qBittorrent Web API is 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.
Installation
Install via pip from PyPI
python -m pip install qbittorrent-api
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.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()
except 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.auth_log_out()
# or use a context manager:
with qbittorrentapi.Client(**conn_info) as qbt_client:
if qbt_client.torrents_add(urls="...") != "Ok.":
raise Exception("Failed to add torrent.")
# display qBittorrent info
print(f"qBittorrent: {qbt_client.app.version}")
print(f"qBittorrent Web API: {qbt_client.app.web_api_version}")
for k, v in qbt_client.app.build_info.items():
print(f"{k}: {v}")
# retrieve and show all torrents
for torrent in qbt_client.torrents_info():
print(f"{torrent.hash[-6:]}: {torrent.name} ({torrent.state})")
# stop all torrents
qbt_client.torrents.stop.all()