|
|
Red Swoosh torrent functionality API documentation
Introduction
This document lists the functions of the Red Swoosh client that are exposed to be used by JavaScript function calls. The Red Swoosh client runs as a webserver on the locahost IP (127.0.0.1) on port 9421.
API requests are made by issuing standard HTTP requests to the client with specially constructed URLs. The available functions, URL formats, and examples of returned data are shown below.
Function: getfileattributes
Description: Returns a list of attributes for a file, given its URL.
URL Format: http://127.0.0.1:9421/jsio?r=RANDOM&f=getfileattributes&i=2&c=CALLBACK&h=0&a0=URL&a2=LONG
Parameters:
RANDOM: this is a random string. It's used to keep web browsers from caching requests and therefore supplying old data. If you're absolutely sure that your browser wont cache requests, then you can omit the entire "r=RANDOM" portion of the request, but this is not recommended. A typical example (using JavaScript) value for RANDOM is to simply use Math.random().
CALLBACK: This is the name of the javascript function that will be called by the response once the web browser receives it. For instance, if you want to run a function called handleResponse() when the Red Swoosh client returns data, then you use "handleResponse" as the value for CALLBACK.
URL: this is simply the URL of the file for which you're looking up attributes. Typically, this will be any of the keys returned by a call to the getfilelist() function.
LONG: this is either the string "long" or "short". It indicates whether you want a long list of attributes for the given file, or a short list. The short list contains the following attributes: none yet.
Additionally, the long list contains these attributes (for torrent files):
rs_download, rs_downloadrate, rs_downloadtorrent, rs_expiration, rs_hash, rs_localurl, rs_metadatahash, rs_name, rs_numswoshpeers, rs_numtorrentpeers, rs_originurl, rs_path, rs_peerrecv, rs_progress, rs_qos, rs_size, rs_status, rs_targetspeed, rs_torrentfilepath, rs_totalrecv, rs_type, rs_uniquerecv
Sample Response:
callback("urlParameter", "short", {
"attr_a": "value1",
"attr_b": "value2",
"attr_c": "value3",
});Function: getfilelist
Description: Returns a list of all currently registered torrent files, as well as their status. Status is one of the following strings: SEARCHING, WAITING, DOWNLOADING, PAUSED, COMPLETE, or INSUFFICIENTDISKSPACE
URL Format: http://127.0.0.1:9421/jsio?r=RANDOM&f=getfilelist&i=2&c=CALLBACK&h=0
Parameters:
RANDOM: this is a random string. It's used to keep web browsers from caching requests and therefore supplying old data. If you're absolutely sure that your browser wont cache requests, then you can omit the entire "r=RANDOM" portion of the request, but this is not recommended. A typical example (using JavaScript) value for RANDOM is to simply use Math.random().
CALLBACK: This is the name of the javascript function that will be called by the response once the web browser receives it. For instance, if you want to run a function called handleResponse() when the Red Swoosh client returns data, then you use "handleResponse" as the value for CALLBACK.
Sample Response:
callback({
"fileURL1": "status1",
"fileURL2": "status2",
"fileURL3": "status3",
"fileURL4": "status4"
});Function: getattribute
Description: Returns a particular attribute of the Red Swoosh client, given that attribute's name.
URL Format: http://127.0.0.1:9421/jsio?r=RANDOM&f=getattribute&i=2&c=CALLBACK&h=0&a0=ATTRIBUTE
Parameters:
RANDOM: this is a random string. It's used to keep web browsers from caching requests and therefore supplying old data. If you're absolutely sure that your browser wont cache requests, then you can omit the entire "r=RANDOM" portion of the request, but this is not recommended. A typical example (using JavaScript) value for RANDOM is to simply use Math.random().
CALLBACK: This is the name of the javascript function that will be called by the response once the web browser receives it. For instance, if you want to run a function called handleResponse() when the Red Swoosh client returns data, then you use "handleResponse" as the value for CALLBACK.
ATTRIBUTE: This is the name of the attribute requested. The available attribute names are:
- rs_authorizeddomain: The domain name authorized to call redswooshInitialize
- rs_cpuuse: The percentage of the machine’s CPU the client is currently using
- rs_cuid: The "customer user ID" set for this customer ID, if any
- rs_customername: The name associated with this CID that appears in the control panel
- rs_customerurl: The URL associated with this CID that appears in the control panel
- rs_downloadrate: The rate at which the client is currently downloading, in bytes per second
- rs_goonline: set to 'true' if the client should download and share files, 'false' otherwise
- rs_isonline: 'true' if currently online
- rs_offlineuistatus: status of the Offline UI (INSTALLED, INTALLING, NOTINSTALLED, or ERRORINSTALLING)
- rs_offlineuiurl: URL from which the Offline UI was last installed; to change, call redswooshInstallOfflineUI
- rs_predeliveriesenabled: set to 'true' to enable predelivery downloads, ‘false’ to disable
- rs_sharerate: The rate at which the client is currently sharing, in bytes per second
Sample Response:
callback("attributeName", "attributeValue");Function: gettorrentattributes
Description: Returns a short list of attributes for each torrent currently registered.
URL Format: http://127.0.0.1:9421/jsio?r=RANDOM&f=gettorrentattributes&i=2&c=CALLBACK&h=0
Parameters:
RANDOM: this is a random string. It's used to keep web browsers from caching requests and therefore supplying old data. If you're absolutely sure that your browser wont cache requests, then you can omit the entire "r=RANDOM" portion of the request, but this is not recommended. A typical example (using JavaScript) value for RANDOM is to simply use Math.random().
CALLBACK: This is the name of the javascript function that will be called by the response once the web browser receives it. For instance, if you want to run a function called handleResponse() when the Red Swoosh client returns data, then you use "handleResponse" as the value for CALLBACK.
Sample Response:
callback({
"torrentBaseURL1": {
"rs_status": "STATUS1",
"rs_error": "ERROR1",
"rs_name": "NAME1",
"rs_peers": "PEERCOUNT1",
"rs_progress": "PROGRESS1",
"rs_collapsed": "COLLAPSED1"
},
"torrentBaseURL2": {
"rs_status": "STATUS2",
"rs_error": "ERROR2",
"rs_name": "NAME2",
"rs_peers": "PEERCOUNT2",
"rs_progress": "PROGRESS2",
"rs_collapsed": "COLLAPSED2"
}
});note: all function call URLs have an i=2 parameter - this indicated the customer ID to use. Torrents always use customer ID 2.
Sign in to add a comment

A function that starts a .torrent download would be very useful. Something like:
http://127.0.0.1:9421/jsio?r=RANDOM&f=starttorrent&i=2&c=CALLBACK&h=0&torrent=URL
starttorrent would download the .torrent file from the remote URL and start downloading the target data
Not sure what the callback response should be... some kind of status code I suppose.
Ok, there is a relatively simple workaround for the open-file API I suggested above, which is to just open a tab with the torrent file.
Here's an even better feature though: Web Seeding (a la: http://wiki.theory.org/BitTorrentSpecification#WebSeeding), specifically the 'second specification' (libtorrent and others support it). The API would have two special arguments: a URL for the remote 'HTTP Seed', and a currently downloading file, as retrieved from getfilelist().