Quick Reference¶
Note
First make sure you’re using WebUI and WebAPI
plugin is active under “Preferences -> Plugins”.
Hints¶
- WebAPI exists alongside with Deluge built-in JSON API, so all HTTP requests should proceed to
http://localhost:8112/json
(or what ever you’ve got instead oflocalhost
)
Use POST method for HTTP requests.
Make requests with valid JSON (including
Accept: application/json
andContent-Type: application/json
HTTP headers).JSON must include the following fields:
id
- message number for identity (could be any, increment it freely)method
- API method name. E.g.:auth.login
,webapi.get_torrents
params
- API method parameters (depend on method)Login beforehand.
- Send
{"id": 1, "method": "auth.login", "params": ["your_password_here"]}
and receive cookies with auth information. - Use those cookies for every request.
- Send
API answers with an error with the following JSON:
{"error": {"message": "Some error description."}, "id": 1, "result": False}
Check responses for
error
field.Make sure Deluge WebUI is connected to Deluge daemon that makes actual torrent processing.
- Send
{"id": 1, "method": "auth.check_session", "params": []}
and verify no error.
- Send
WebAPI method names start with
webapi.
. (E.g.:webapi.add_torrent
to calladd_torrent
function).See https://github.com/idlesign/deluge-webapi/blob/master/webapi/test.py for code sample. Run it for basic debug.
Debug¶
If you have problems with plugin activation, you can get log with useful information (look for string containing webapi
).
For deluged
:
$ deluged -d -L info
For deluged-web
:
$ deluge-web -L info
You can run https://github.com/idlesign/deluge-webapi/blob/master/webapi/test.py for basic test.
API Methods¶
Note
WebAPI uses torrent hashes to identify torrents, so torrent ID is the same as hash.
Get torrents info¶
get_torrents(ids=None, params=None)
Returns information about all or a definite torrent. Returned information can be filtered by supplying wanted parameter names.
Add torrent¶
add_torrent(metainfo, options=None)
Adds a torrent with the given options. metainfo could either be base64 torrent data or a magnet link.
Remove torrent¶
remove_torrent(torrent_id, remove_data=False)
Removes a given torrent. Optionally can remove data.