The cursor parameter is an essential tool for managing paginated data retrieval when working with specific API endpoints. This parameter allows you to navigate through large datasets by specifying the position within a list of results. The cursor-based pagination is implemented in the following endpoints:
When you make a request to any of these endpoints, the API response will include a field in the JSON body called "next_cursor". This value serves as a pointer to the next set of results in the paginated list.
cursor parameter to retrieve the first page of results.next_cursor value from the response as the cursor parameter in your next API request.next_cursor value from subsequent responses until the "next_cursor" field is empty or null, indicating the end of the dataset.Make a request to an endpoint without the cursor parameter. For example:
curl -X GET "https://api.scraper.tech/followers.php?screenname=elonmusk" \
-H "Scraper-Key: YOUR_UNIQUE_KEY"
{
"followers": [
{"id": 1, "name": "John Doe"},
{"id": 2, "name": "Jane Smith"}
],
"next_cursor": "abc123"
}
Use the value of "next_cursor" in your subsequent request:
curl -X GET "https://api.scraper.tech/followers.php?screenname=elonmusk&cursor=abc123" \
-H "Scraper-Key: YOUR_UNIQUE_KEY"
{
"followers": [
{"id": 3, "name": "Alice Brown"},
{"id": 4, "name": "Bob White"}
],
"next_cursor": "def456"
}
Repeat the process with the updated cursor parameter until the "next_cursor" field is empty or null.
{
"followers": [],
"next_cursor": null
}
"next_cursor" field is null before making the next request.
By using the cursor parameter effectively, you can retrieve large datasets efficiently and maintain seamless pagination across multiple API endpoints.