Clarification of the Tribler API

Hello there :slightly_smiling_face:

I use tribler via a docker container on a server usable only with terminal.
I code a simple bash script to interact with Tribler.
I can start a download via a magnet link, stop, delete a download.
So I’ve got the bare minimum.

I see that the API allows me to perform a search (https://tribler.readthedocs.io/en/latest/restapi/search.html). But how can I download one of the items returned by the search?
“The URI of the torrent file that should be downloaded. This URI can either represent a file location, a magnet link or a HTTP(S) url” (https://tribler.readthedocs.io/en/latest/restapi/downloads.html#put–downloads). What do you mean by “file location”? What parameter returned by the search can be sent to Tribler to start a download?

Another thing, the URL “/torrentinfo” seems to be able to return some interesting information. In particular, I need to retrieve the file(s) / folder(s) names of a torrent already active on Tribler. But I can’t get it to work, either for a download in progress or via a magnet link. I’ve tried passing the URL parameters “/torrentinfo?torrent=”, “/torrentinfo?uri=” and then a magnet link or url encoded magnet link without success.
Oh, and adding parameter to URL “/downloads?get_files=true” does not seem to work (https://tribler.readthedocs.io/en/latest/restapi/downloads.html#get–downloads).

Finally, is it possible to retrieve information from a single download without having to parse all the information from all the downloads managed by Tribler ("'GET /downloads") ?

Thanks in advance
Have a good day :rainbow:

2 Likes

“GET /downloads/{infohash}/files” do the job to retrieve the file(s) / folder(s) names of a torrent already active.

1 Like

Hello

I see that the API allows me to perform a search (Search — Tribler 7.5.0 documentation). But how can I download one of the items returned by the search?

Thanks for your help

1 Like

Did you find the information you were looking for in the end? also interested.

Hi Alakaza

Not at all.
However, I’m just starting to use version 8.5 with the web UI and that’s perfect.

1 Like

When interacting with Tribler’s API, the term “file location” refers to a valid URI (Uniform Resource Identifier) that can be used to initiate a download. This can be either a magnet link (which uniquely identifies a torrent), a URL pointing to a .torrent file, or a file path if you’re working with a local torrent file. In the context of the Search API, the returned results typically include a uri field, which will usually be a magnet link that you can use to start a download. To download a torrent from the search results, you should extract the uri (magnet link) from the search response and then use the PUT /downloads endpoint to initiate the download by passing this URI as a parameter.

Regarding retrieving file or folder names of a torrent already active on Tribler, you should be able to use the /torrentinfo endpoint by passing either the torrent hash or the magnet link (properly URL-encoded) as a query parameter. The torrent or uri parameters can be used for this purpose. If you’re having trouble, ensure the magnet link is correctly URL-encoded and that the torrent is indeed active or downloaded. As for the /downloads?get_files=true parameter, it seems it doesn’t function as expected in your case, which could be due to the API’s current limitations or an issue with how the request is formed.

Finally, to retrieve information about a single download without parsing all downloads, the GET /downloads endpoint will typically return information about all downloads. Unfortunately, the API doesn’t seem to provide a direct way to query for a specific download by its identifier, so you’ll need to parse the list of downloads and filter for the one you’re interested in. A potential workaround would be to parse the results based on a specific attribute (such as the torrent hash or name) to isolate the relevant download.