Quantcast
Channel: Questions in topic: "httpwebrequest"
Viewing all articles
Browse latest Browse all 190

API pagination

$
0
0
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 } . . . }

Viewing all articles
Browse latest Browse all 190

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>