Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

API to flood #858

Open
jvacek opened this issue Jan 18, 2020 · 3 comments
Open

API to flood #858

jvacek opened this issue Jan 18, 2020 · 3 comments

Comments

@jvacek
Copy link

jvacek commented Jan 18, 2020

Type: Feature Request

Summary

It would be nice to interact with flood using a Restful API. This way you could directly add torrents via plugins or userscripts, could make a mobile client for Android/iOS, basically whatever.

Idea of implementation

I'm not coming from a JS background but it seems a pcakage like this could essentially implement this functionality quite well. https://www.npmjs.com/package/express-nedb-rest.

@damolp
Copy link
Contributor

damolp commented Mar 5, 2020

rtorrent already exposes an API over XML-RPC which is what Flood uses. Adding something like this into Flood seems redundant?

@briangordon
Copy link

briangordon commented May 16, 2020

rtorrent's XML-RPC API talks SCGI, which is not widely supported and difficult to query.

As far as I know it would be impossible to write a userscript that talks directly to this API because you need to be able to open a socket and immediately send SCGI headers instead of an HTTP request line.

Even in a command-line environment, if rtorrent is in daemon mode without pyrocore and you just need to send a command to it and correctly receive the response, I think the quickest way to do that currently is to go find somebody's toy SCGI client library and write some code against it to send a hand-crafted XML-RPC request.

In order for a client to talk to rtorrent (or any SCGI server) easily you really need to be running a server that accepts HTTP requests and proxies them as SCGI requests. ngx_http_scgi_module does this for nginx, and mod_proxy_scgi does this for apache. But since Flood is already running, and already understands SCGI and connects to rtorrent, it seems duplicative to run a separate server. It would definitely be convenient to be able to curl a Flood endpoint and be able to write a userscript that does the same thing from the browser. I think @jvacek's suggestion is a good idea, provided the feature is disabled by default and Flood just transliterates JSON requests directly into rtorrent API calls rather than inventing its own API.

(By the way, ruTorrent basically already provides this feature as a plugin. The API is undocumented but it looks like among the logic coupled to their frontend is a code path that lets you pass commands directly through to rtorrent. I'd personally rather not use ruTorrent though, because I like Flood better and running them both simultaneously against the one rtorrent socket seems to break rtorrent somehow.)

@jesec
Copy link
Member

jesec commented Jan 31, 2021

Flood API is well documented with inline comments and TypeScript types. Additionally, Flood now guarantees API backward compatibility, per conventions of Sematic Versioning. Please try the latest version of Flood.

For instance, /api/torrents/add-urls: https://github.com/jesec/flood/blob/2c747d771ea66dbe8c906e1eb1904f4a801d052f/server/routes/api/torrents.ts#L108-L116

Feel free to close the issue if it is no longer relevant.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants