Python examples for the WebAPI

Other platforms, generic questions.
Post Reply
Marqus

Python examples for the WebAPI

Post by Marqus »

I have not found Python examples for the WebAPI, and my own examples don't work.
Could someone correct the examples below or link to working examples?
Thank you.

The WebAPI is documented here
https://github.com/qbittorrent/qBittorr ... umentation


This Python script should shutdown qBittorrent-nox
import requests
from requests.auth import HTTPDigestAuth
response = requests.get('http://127.0.0.1:8080/command/shutdown', auth=HTTPDigestAuth("admin", "adminadmin"))
if not response.ok:
    response.raise_for_status()
response.content
No effect The script returns without error, but qBittorrent-nox still runs.
=====================================

This Python script should list the torrents
import requests
from requests.auth import HTTPDigestAuth
response = requests.get('http://127.0.0.1:8080/json/torrents', auth=HTTPDigestAuth("admin", "adminadmin"))
if not response.ok:
    response.raise_for_status()
response.content
Negative Result The script throws HTTPError: 404 Client Error: File not found
======================================
sign

Re: Python examples for the WebAPI

Post by sign »

I tested this thing and it is working as it should in the latest qBittorrent versions :)
Swairard

Re: Python examples for the WebAPI

Post by Swairard »

This is quite an interesting idea
sledgehammer_999
Administrator
Administrator
Posts: 2443
Joined: Sun Jan 23, 2011 1:17 pm

Re: Python examples for the WebAPI

Post by sledgehammer_999 »

V3.2.0 will have a new WebAPI. Part of it is documented here: https://gist.github.com/pmzqla/7e5733dbecfc50ee4ecd
Look also the end of the page in the comments. There is talk on how the new authentication method works.
The whole API can be found here with some rudimentary documentations: https://github.com/qbittorrent/qBittorr ... cation.cpp
kkuriyama

Re: Python examples for the WebAPI

Post by kkuriyama »

Here is an example Python script that logins into a qbittorrent server, downloads the list of torrents, sorts the list, and then prints it out.  The script is expecting the URL of the torrent server:

    ./example.py torrentserver.com

I've tested this on qbittorrent version 3.3.10.  Note that the authentication method for version3.3.10 is different that earlier version and thus the change in the Python script.
Attachments

[The extension has been deactivated and can no longer be displayed.]

Post Reply