Pagination
In this guide, we will look at how to work with paginated responses when querying the Browserhub API. By default, all responses limit results to 50.
In paginated responses, objects are nested in a data
attribute. The payload
also has a next_page
attribute that indicates the next page of the data.
Then we know that we reached the end of the page when the value of next_page
is null
.
Example using page attribute
In this example, we request scrapers from the page number 2.
As a result, we get a list of 2 scrapers.
You can see that the value of next_page
attribute is null
.
That means we have reached the end of the resultset.
- Name
page
- Type
- integer
- Description
Page number of the request. Omitting this will make the API assume that you're requesting the 1st page.
Request
GET
/v1/scraperscurl -G https://api.browserhub.io/v1/scrapers \
-H "Authorization: Bearer {API key}" \
-d page=2
Paginated response
{
"next_page": null,
"data": [
{
"id": "f4fcf5a4-730d-4dab-b0cb-c7433810266a",
// ...
},
{
"id": "fdd28450-3886-442c-9be1-b1d69721a785",
// ...
}
]
}