Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Call to get torrent count #19731

Closed
ElAdri1999 opened this issue Oct 18, 2023 · 3 comments · Fixed by #19831
Closed

API Call to get torrent count #19731

ElAdri1999 opened this issue Oct 18, 2023 · 3 comments · Fixed by #19831
Labels
Documentation Feature request WebAPI WebAPI-related issues/changes

Comments

@ElAdri1999
Copy link

ElAdri1999 commented Oct 18, 2023

Suggestion

I am making a multiplatform app and i am having issues with loading the whole torrent list when clients have very big amount of torrents (testing on a client with over 7k) and i am working around it by doing smaller calls with offset and limit but i haven't found a way to know how many torrents are there in total to stop calling the API when that amount is reached.

Use case

int batchsize = 20;
int offset = 0;
bool hasmorecontent = true;
while (hasmorecontent)
{
    HttpClient client = GenerateHttpClient();
    HttpRequestMessage request = GenerateHttpRequestMessage(APIAddresses.TorrentsList + "?offset=" + offset + "&limit=" + batchsize);
    HttpResponseMessage response = await client.SendAsync(request);
    var taskResponse = response.Content.ReadAsStringAsync();
    taskResponse.Wait();
    var result = taskResponse.Result;
    Console.WriteLine("===> " + taskResponse.Result);
    /*
    if (result.StartsWith("["))
    {
        result = result.Substring(1, result.Length - 2);
    }
    */
    var convert = JsonConvert.DeserializeObject<List<TorrentJSON>>(result);
   //DataHandling logic here
    offset += batchsize;
if(offset>=**APICALL Torrent Count**)
hasmorecontent=false;
}

Extra info/examples/attachments

No response

@thalieht thalieht added the WebAPI WebAPI-related issues/changes label Oct 18, 2023
@luzpaz
Copy link
Contributor

luzpaz commented Oct 18, 2023

Where in the docs did you look, btw ?

@ElAdri1999
Copy link
Author

ElAdri1999 commented Oct 18, 2023

Where in the docs did you look, btw ?

https://github.com/qbittorrent/qBittorrent/wiki/WebUI-API-(qBittorrent-4.1)#torrent-management

I looked there, could not find any way in the whole wiki to call for a torrent count

@luzpaz
Copy link
Contributor

luzpaz commented Oct 23, 2023

@xavier2k6 any idea ?

glassez added a commit to glassez/qBittorrent that referenced this issue Oct 30, 2023
glassez added a commit that referenced this issue Nov 2, 2023
glassez added a commit to glassez/qBittorrent that referenced this issue Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Feature request WebAPI WebAPI-related issues/changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants