qBittorrent WebUI API Help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
metallizer
Posts: 31
Joined: 13 Aug 2021, 13:34

qBittorrent WebUI API Help

Post by metallizer » 05 Oct 2022, 23:27

Because the WebUI will lock me out for multiple attempts (because to some unknown setup issues, I'm unable to raise the login attempt tries or shorten the lock out period), I am unable to use the trial and error method to make this work Please help.

I trying to add the torrent url to qBittorrent WebUI using ahk. Below is the api documentation for that:

General Information
  • All API methods follows the format /api/v2/APIName/methodName, where APIName is a certain subgroup of API methods whose functionality is related.
  • All API methods only allows GET or POST methods. Use POST when you are mutating some state (or when your request is too big to fit into GET) and use GET otherwise. Starting with qBittorrent v4.4.4, server will return 405 Method Not Allowed when you used the wrong request method.
  • All API methods require authentication (except /api/v2/auth/login, obviously).
Authentication
All Authentication API methods are under "auth", e.g.: /api/v2/auth/methodName.
qBittorrent uses cookie-based authentication.

Login
Name: login

Parameters:
Parameter - username
Type - string
Description - Username used to access the WebUI


Parameter - password
Type - string
Description - Password used to access the WebUI

Returns:
HTTP Status Code - 403
Scenario - User's IP is banned for too many failed login attempts

HTTP Status Code - 200
All other scenarios

Upon success, the response will contain a cookie with your SID. You must supply the cookie whenever you want to perform an operation that requires authentication.

Example showing how to login and execute a command that requires authentication using curl:

Code: Select all

$ curl -i --header 'Referer: http://localhost:8080' --data 'username=admin&password=adminadmin' http://localhost:8080/api/v2/auth/login
HTTP/1.1 200 OK
Content-Encoding:
Content-Length: 3
Content-Type: text/plain; charset=UTF-8
Set-Cookie: SID=hBc7TxF76ERhvIw0jQQ4LZ7Z1jQUV0tQ; path=/
$ curl http://localhost:8080/api/v2/torrents/info --cookie "SID=hBc7TxF76ERhvIw0jQQ4LZ7Z1jQUV0tQ"
Note: Set Referer or Origin header to the exact same domain and port as used in the HTTP query Host header.

Add new torrent
This method can add torrents from server local file or from URLs. http://, https://, magnet: and bc://bt/ links are supported.

Add torrent from URLs example:

Code: Select all

POST /api/v2/torrents/add HTTP/1.1
User-Agent: Fiddler
Host: 127.0.0.1
Cookie: SID=your_sid
Content-Type: multipart/form-data; boundary=---------------------------6688794727912
Content-Length: length

-----------------------------6688794727912
Content-Disposition: form-data; name="urls"

https://torcache.net/torrent/3B1A1469C180F447B77021074DBBCCAEF62611E7.torrent
https://torcache.net/torrent/3B1A1469C180F447B77021074DBBCCAEF62611E8.torrent
-----------------------------6688794727912
Content-Disposition: form-data; name="savepath"

C:/Users/qBit/Downloads
-----------------------------6688794727912
Content-Disposition: form-data; name="cookie"

ui=28979218048197
-----------------------------6688794727912
Content-Disposition: form-data; name="category"

movies
-----------------------------6688794727912
Content-Disposition: form-data; name="skip_checking"

true
-----------------------------6688794727912
Content-Disposition: form-data; name="paused"

true
-----------------------------6688794727912
Content-Disposition: form-data; name="root_folder"

true
-----------------------------6688794727912--
The above example will add two torrent files. file_binary_data_goes_here represents raw data of torrent file (basically a byte array).
Image

Returns:
HTTP Status Code - 415
Torrent file is not valid

HTTP Status Code - 200
All other scenarios

Please help to add the torrent file url to the qBittorrent WebUI. Thanks in advance.

Complete Documentation of WebUI:
https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)


Post Reply

Return to “Ask for Help (v1)”