Downloads

class Tribler.Core.Modules.restapi.downloads_endpoint.DownloadExportTorrentEndpoint(session, infohash)[source]

This class is responsible for requests that are exporting a download to a .torrent file.

render_GET(request)[source]
GET /download/(string: infohash)/torrent

A GET request to this endpoint returns the .torrent file associated with the specified download.

Example request:

curl -X GET http://localhost:8085/downloads/4344503b7e797ebf31582327a5baae35b11bda01/torrent

Example response:

The contents of the .torrent file.

class Tribler.Core.Modules.restapi.downloads_endpoint.DownloadFilesEndpoint(session, infohash)[source]

This class is responsible for requests that request the files of a specific torrent.

render_GET(request)[source]
GET /download/(string: infohash)/files

A GET request to this endpoint returns the file information of a specific download.

Example request:

curl -X GET http://localhost:8085/downloads/4344503b7e797ebf31582327a5baae35b11bda01/files

Example response:

{
    "files": [{
        "index": 1,
        "name": "test.txt",
        "size": 12345,
        "included": True,
        "progress": 0.5448
    }, ...]
}
class Tribler.Core.Modules.restapi.downloads_endpoint.DownloadsEndpoint(session)[source]

This endpoint is responsible for all requests regarding downloads. Examples include getting all downloads, starting, pausing and stopping downloads.

render_GET(request)[source]
GET /downloads?get_peers=(boolean: get_peers)&get_pieces=(boolean: get_pieces)

A GET request to this endpoint returns all downloads in Tribler, both active and inactive. The progress is a number ranging from 0 to 1, indicating the progress of the specific state (downloading, checking etc). The download speeds have the unit bytes/sec. The size of the torrent is given in bytes. The estimated time assumed is given in seconds. A description of the possible download statuses can be found in the REST API documentation.

Detailed information about peers and pieces is only requested when the get_peers and/or get_pieces flag is set. Note that setting this flag has a negative impact on performance and should only be used in situations where this data is required.

Example request:

curl -X GET http://localhost:8085/downloads?get_peers=1&get_pieces=1

Example response:

{
    "downloads": [{
        "name": "Ubuntu-16.04-desktop-amd64",
        "progress": 0.31459265,
        "infohash": "4344503b7e797ebf31582327a5baae35b11bda01",
        "speed_down": 4938.83,
        "speed_up": 321.84,
        "status": "DLSTATUS_DOWNLOADING",
        "size": 89432483,
        "eta": 38493,
        "num_peers": 53,
        "num_seeds": 93,
        "total_up": 10000,
        "total_down": 100000,
        "ratio": 0.1,
        "files": [{
            "index": 0,
            "name": "ubuntu.iso",
            "size": 89432483,
            "included": True
        }, ...],
        "trackers": [{
            "url": "http://ipv6.torrent.ubuntu.com:6969/announce",
            "status": "Working",
            "peers": 42
        }, ...],
        "hops": 1,
        "anon_download": True,
        "safe_seeding": True,
        "max_upload_speed": 0,
        "max_download_speed": 0,
        "destination": "/home/user/file.txt",
        "availability": 1.234,
        "peers": [{
            "ip": "123.456.789.987",
            "dtotal": 23,
            "downrate": 0,
            "uinterested": False,
            "wstate": "",
            "optimistic": False,
            ...
        }, ...],
        "total_pieces": 420,
        "vod_mod": True,
        "vod_prebuffering_progress": 0.89,
        "vod_prebuffering_progress_consec": 0.86,
        "error": "",
        "time_added": 1484819242,
    }
}, ...]
render_PUT(request)[source]
PUT /downloads

A PUT request to this endpoint will start a download from a provided URI. This URI can either represent a file location, a magnet link or a HTTP(S) url. - anon_hops: the number of hops for the anonymous download. 0 hops is equivalent to a plain download - safe_seeding: whether the seeding of the download should be anonymous or not (0 = off, 1 = on) - destination: the download destination path of the torrent - torrent: the URI of the torrent file that should be downloaded. This parameter is required.

Example request:

curl -X PUT http://localhost:8085/downloads
--data "anon_hops=2&safe_seeding=1&destination=/my/dest/on/disk/&uri=file:/home/me/test.torrent

Example response:

{"started": True, "infohash": "4344503b7e797ebf31582327a5baae35b11bda01"}