Can't access webAPI with webUI works

Linux specific questions, problems.
Post Reply
whitebear

Can't access webAPI with webUI works

Post by whitebear »

I am using qbittorrent-nox v 2.9.8(Web UI)

I can access top page via browser or curl.
curl localhost:7097/

However I tried to access web API like this.

curl localhost:7097/version/api
curl localhost:7097/login

Nothing appeared.

My qbittorrent was installed by NAS (Readynas), so it might have some special setting though,

Do you think why I can't access web API??

How could it be that web UI works and web API not works ?
mhertz

Re: Can't access webAPI with webUI works

Post by mhertz »

I also just spent some time figuring this out i.e. how to control qbittorrent-nox through it's web-API with curl, as I just finished writing a bash-script which upon clicking a torrent or magnet link in firefox, silently starts the daemon and download in the background and when all downloads are finished then the qbittorrent-nox daemon is killed off and a sound is played as notification(during download I can of course just open the web-UI in a new tab to monitor progress if wanted). I had the same setup made for deluged when using that previously.

Anyway, you need to send POST http command to login to the daemon(curl by default uses GET http command), and which is done by '--data' and '-i' is for only returning header back.

Code: Select all

curl -i --data "username=admin&password=adminadmin" http://localhost:8080/login
Then you get returned a response which also includes a cookie-hash which you will need to pass on with the next commands, e.g.

Code: Select all

curl http://localhost:8080/query/torrents --cookie "SID=xxxxxxxxxxxxxxxxxxxxxxxx"
Personally, to simplify my script, then I added the following config-setting to '~/.config/qBittorrent/qBittorrent.conf' which disables authentication from localhost connections i.e. no cookies needed from there:

Code: Select all

WebUI\LocalHostAuth=false
The browser supplies the cookie automatically when accessing the web-UI, so that's why you have issues when doing it manually(+ you need to send POST commands often with '--data').

The web-API is nicely documented, though I personally only needed to access one command from it in my script to see if any downloads left(/query/torrents) before pkill'ing qbittorrent-nox off.
Last edited by mhertz on Tue Aug 23, 2016 11:11 am, edited 1 time in total.
whitebear

Re: Can't access webAPI with webUI works

Post by whitebear »

Thanks mhertz.

However, your problem might be different from my problem.


curl -i --data "username=admin&password=adminadmin" http://localhost:7097/login

This returns HTTP/1.1 404 File not found

curl http://localhost:7097/

returns html though.

Web API is concealed somehow in my circumstances??
However how the application handles my login status...??
Post Reply