This will return all users from the leaderboard but the API has a limit of 1000 calls. I have in the leaderboard more than 1000 users and it's always increases. I need to save all the users to a list.
I know I have to work with offset= for the next calls.
What is the best practice to handle this?
The code:
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri("https://api.streamelements.com/kappa/v2/points/123/top?limit=1000&offset=0"),
Headers =
{
{ "Accept", "application/json" },
{ "Authorization", "Bearer 123" },
},
};
using (var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
}
The Body:
{
"_total": 1186,
"users": [
{
"username": "test1",
"points": 1
},
{
"username": "test2",
"points": 3
}
.
.
.
}
↧