Search code examples
javascriptrestpaginationjson-api

Getting data from a REST API with no pagination beside page parameter


I want to move some data from an API into Elasticsearch inside my JS app. The documentation of the API says:

The API is a classic REST JSON API. {...} To request another page use the page parameter.

Is there a way to find out whether there are additional data when I increase the page parameter incrementally without requesting the non-existing last page?


Solution

  • Does the API provide you with a total count of items? I would expect a total number of items to be available somewhere (perhaps in the initial call?) - you can then do some simple maths within your JavaScript to figure out how many pages there are and when to stop calling for more.