deluge-webapi documentation¶
https://github.com/idlesign/deluge-webapi
Description¶
Plugin for Deluge WebUI providing sane JSON API.
Exposes some sane JSON API through Deluge WebUI (missing out of the box or restyled) so that you can manipulate Deluge from your programs using HTTP requests.
Requirements¶
- Python 2.7+
- Deluge 1.3.15+
Installation¶
Get plugin egg file, from
dist/
(https://github.com/idlesign/deluge-webapi/tree/master/dist) directory.Open Deluge Web UI, go to “Preferences -> Plugins -> Install plugin” and choose egg file.
Note
To build .egg file from source code yourself use python setup.py bdist_egg command in source code directory.
Activate WebAPI plugin.
You’re ready.
Table of Contents¶
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.
Get involved into deluge-webapi¶
Submit issues. If you spotted something weird in application behavior or want to propose a feature you can do that at https://github.com/idlesign/deluge-webapi/issues
Write code. If you are eager to participate in application development, fork it at https://github.com/idlesign/deluge-webapi, write your code, whether it should be a bugfix or a feature implementation, and make a pull request right from the forked project page.
Spread the word. If you have some tips and tricks or any other words in mind that you think might be of interest for the others — publish it.
More things¶
- You might be interested in considering other Deluge plugins at http://dev.deluge-torrent.org/wiki/Plugins/
- Or you might be interested in a PHP Deluge API wrapper: https://github.com/kaysond/deluge-php