Page 1 of 1

Python examples for the WebAPI

Posted: Fri Oct 17, 2014 8:15 pm
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
======================================

Re: Python examples for the WebAPI

Posted: Thu Apr 02, 2015 11:38 pm
by sign
I tested this thing and it is working as it should in the latest qBittorrent versions :)

Re: Python examples for the WebAPI

Posted: Wed Apr 08, 2015 7:38 pm
by Swairard
This is quite an interesting idea

Re: Python examples for the WebAPI

Posted: Fri Apr 10, 2015 1:24 am
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

Re: Python examples for the WebAPI

Posted: Fri Mar 10, 2017 8:16 am
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.