This repository has been archived by the owner on Jun 15, 2023. It is now read-only.
forked from jpillora/cloud-torrent
-
Notifications
You must be signed in to change notification settings - Fork 309
RestfulAPI
Preston edited this page Jan 3, 2020
·
1 revision
Most of the common actions can be controlled over the restful API.
The Restful API can be access via both the trusted port (defined by arg --rest-api
or the regular web port with authtication.)
- POST
/api/url
curl --data "http://file-of-a-remote-torrent-url/file.torrent" "http://localhost:3001/api/url"
- POST
/api/torrentfile
curl --data-binary @my.torrent "http://localhost:3001/api/torrentfile"
- POST
/api/magnet
curl --data "magnet:?xt=urn:btih:..." "http://localhost:3001/api/magnet"
- GET
/api/torrents
- GET
/api/torrent/abcd123456abcd123456abcd123456abcd123456
eg: http http://localhost:3001/api/torrents
List the details of the torrents that are actives. /api/torrents
lists all, while /api/torrent/...
gets one of them.
{
"abcd123456abcd123456abcd123456abcd123456": {
"AddedAt": "2020-01-03T16:40:01.88092268+08:00",
"Done": false,
"DoneCmdCalled": false,
"DownloadRate": 944601.7,
"Downloaded": 2834432,
"Files": [
{
"Completed": 0,
"Done": false,
"DoneCmdCalled": false,
"Path": "NameOfTheFile.mp4",
"Percent": 0,
"Size": 722847513,
"Started": true
}
],
"InfoHash": "abcd123456abcd123456abcd123456abcd123456",
"Loaded": true,
"Magnet": "magnet:?xt=urn:btih:...",
"Name": "NameOfTheTorrent",
"Percent": 0.09,
"SeedRatio": 0.0028273743,
"Size": 2927978404,
"Started": true,
"StartedAt": "2020-01-03T16:40:02.383222715+08:00",
"Stats": {
...........omited, see https://github.com/anacrolix/torrent/blob/master/conn_stats.go
},
"UploadRate": 0,
"Uploaded": 0
}
}
- GET
/api/files
eg: http http://localhost:3001/api/files
List the files in the download directory. It's a nested structure of directory and files.
{
"Children": [
{
"Children": [
{
"Children": null,
"Modified": "2020-01-03T16:40:13.60421924+08:00",
"Name": "NameOfTheFile1.mp4",
"Size": 34224359
}
],
"Modified": "2020-01-03T16:40:09.248219284+08:00",
"Name": "NameOfTheDir",
"Size": 883443750
}
],
"Modified": "2020-01-03T16:40:03.124619355+08:00",
"Name": "downloads",
"Size": 883443750
}
- POST
/api/torrent
HASH=abcd123456abcd123456abcd123456abcd123456
# to start the task
curl --data "start:${HASH}" "http://localhost:3001/api/torrent"
# to stop the task
curl --data "stop:${HASH}" "http://localhost:3001/api/torrent"
# to remove the task
curl --data "delete:${HASH}" "http://localhost:3001/api/torrent"
- POST
/api/file
HASH=abcd123456abcd123456abcd123456abcd123456
# to start the file
curl --data "start:${HASH}:NameOfTheFile1.mp4" "http://localhost:3001/api/file"
# to stop the file
curl --data "stop:${HASH}:NameOfTheFile1.mp4" "http://localhost:3001/api/file"
- GET
/api/stat
{
"Runtime": "1.13.5",
"System": {
"cpu": 1.7025538307471353,
"diskFree": 20868198400,
"diskUsedPercent": 67.75702723749691,
"goMemory": 5348720,
"goRoutines": 304,
"memUsedPercent": 18.995308053990264,
"set": true
},
"Title": "SimpleTorrent",
"Uptime": "2020-01-03T17:03:45.829239678+08:00",
"Version": "1.1.4-4-gbe13cee"
}
- POST
/api/configure
curl --data-binary @newconfig.json "http://localhost:3001/api/configure"