qbittorrent-api

rmartin16MIT活跃维护

用 Python 调用 qBittorrent Web API 的客户端库,方便脚本化地管理种子任务、查询下载状态和自动化操作。

Python client implementation for qBittorrent's Web API

v2026.10.1发布于 2026-10-21 05:49 UTC518star +1 / 7 天77fork同步于 2026-11-12 06:03 UTC

怎么上手

由 README 提炼,执行前请确认
python -m pip install qbittorrent-api
硬件要求按 README 说明

README 未说明;这是纯 Python 客户端库,本身无 GPU 或显存要求,只需能访问 qBittorrent WebUI 的网络环境

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Python 调用 qBittorrent Web API 的客户端库,省去手写 HTTP 请求和版本兼容处理

用 Python 调用 qBittorrent Web API 的客户端库,方便脚本化地管理种子任务、查询下载状态和自动化操作。

核心能力

  • 完整实现 qBittorrent Web API 全部端点
  • 自动检测 qBittorrent 版本以匹配端点特性
  • 认证 cookie 过期时随请求自动重新登录
  • 支持上下文管理器自动登入登出
  • 提供 torrents、app 等分类对象式调用接口

容易踩的坑

需先自行部署并开启 qBittorrent 的 WebUI,默认端口 8080;默认凭据为 admin/adminadmin,实际使用需替换;客户端长期存活或频繁创建时记得调用 auth_log_out 或使用 with 语句

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2026.10.1
  1. v2026.10.1release-2026.10.1最新正式版2026-10-21 · 2026-10-21 05:49 UTC

    What's Changed

    Features

    Chores

    Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.10.0...v2026.10.1

  2. v2026.10.0release-2026.10.02026-10-03 · 2026-10-03 16:20 UTC
    查看更新说明

    What's Changed

    Features

    Chores

    CI

    Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.8.1...v2026.10.0

  3. v2026.8.1release-2026.8.12026-08-16 · 2026-08-16 20:30 UTC
    查看更新说明

    What's Changed

    Features

    Fixes

    Chores

    Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.8.0...v2026.8.1

  4. v2026.8.0release-2026.8.02026-08-01 · 2026-08-01 21:05 UTC
    查看更新说明

    What's Changed

    Fixes

    CI

    Chores

    New Contributors

    Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.7.0...v2026.8.0

  5. v2026.7.0release-2026.7.02026-07-08 · 2026-07-08 00:54 UTC
    查看更新说明

    What's Changed

    Fixes

    Chores

    Full Changelog: https://github.com/rmartin16/qbittorrent-api/compare/v2026.6.1...v2026.7.0

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    qBittorrent Web API Client

    Python client implementation for qBittorrent Web API

    GitHub Workflow Status (branch) Codecov branch PyPI PyPI - Python Version

    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()