C
C#β€’2y ago
Cuda

❔ How to read json api data from remote server that uses paging?

So I need some direction of how we can pull all data from a json api website that only sends 50 items per page. I can pull json data successfully but I only get the first 50 items out of at least 1030 items total. How do we make the server give us the rest of the data? On my end what structure would I use to build or receive it?
10 Replies
jcotton42
jcotton42β€’2y ago
that depends on the API read its docs, it will have instructions on how to get more pages
Angius
Angiusβ€’2y ago
Usually there's some ?page=3 or whatever param
Cuda
Cudaβ€’2y ago
Yes It does say that.. However how do we build the list to receive all of it? @jcotton42
Angius
Angiusβ€’2y ago
Loop it Get all the lists Assemble one
pip
pipβ€’2y ago
careful with ratelimits when paginating that way tho πŸ˜„
Cuda
Cudaβ€’2y ago
Yeah dont want to get blacklisted
Henkypenky
Henkypenkyβ€’2y ago
it probably uses OData depending on the version but you should get a string for your next request (your next page) something like Odata_next_page: "api/foo/items?$skip20" or something like that you can add logic to your code to map your pagination to the requests using this data
jcotton42
jcotton42β€’2y ago
"probably" based on what?
Henkypenky
Henkypenkyβ€’2y ago
just guessing but if it paginates it should send the next link or whatever in the response following good practice
Accord
Accordβ€’2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity. Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.