Skip to main content

Pagination

The Google Search API supports pagination to retrieve multiple pages of search results. The page parameter allows you to specify which page of results you want to retrieve.

Pagination Parameter

ParameterTypeRequiredDefaultRange
pagenumberNonull1-100

How Pagination Works

  • When page is not specified (null), the API returns the first page of results
  • Valid page numbers are between 1 and 100, if no page number is specified, it will default to the first page, so empty page is equivalent to page=1.
  • The actual number of available pages depends on Google's results for your query
  • Google may return fewer than 100 pages even if more results exist
  • Requesting a page number higher than available pages will return an empty organic_results array

Example Requests

First page (default):

curl -X 'GET' \
'https://app.serpextractor.com/api/google?query=café&location=Paris%2CParis%2CIle-de-France%2CFrance' \
-H 'X-API-Key: YOUR_API_KEY'

Specific page:

curl -X 'GET' \
'https://app.serpextractor.com/api/google?query=café&location=Paris%2CParis%2CIle-de-France%2CFrance&page=2' \
-H 'X-API-Key: YOUR_API_KEY'

Response Handling

The response format remains the same regardless of the page requested. You can determine if you've reached the end of available results when either:

  1. The organic_results array is empty
  2. The number of results is less than the typical page size

Best Practices

  1. Start from page 1: Always start pagination from the first page and increment sequentially
  2. Handle empty results: Your application should gracefully handle cases where organic_results is empty

Error Cases

Error CaseResponse
Page > 100Status 400 - Invalid page number
Page < 1Status 400 - Invalid page number
Page > available resultsStatus 200 with empty organic_results
Non-numeric pageStatus 400 - Invalid page format

Example Response with Pagination

{
"organic_results": [
{
"position": 11, // Position now starts from 11 for page 2
"title": "Example Result",
"link": "https://example.com",
"content": "Result description..."
}
// ... more results
],
"metadata": {
"status": "Success",
"request_id": "c6c97438-52f2-4a8e-a5ce-9297393d6a39",
"created_at": "2024-11-13T08:54:32.057395+00:00",
"updated_at": "2024-11-13T08:54:32.062946",
"params": {
"query": "café",
"location": "Paris,Paris,Ile-de-France,France",
"page": "2",
// ... other parameters
}
}
}
caution

Be aware that Google search results can change frequently, so paginated results might not be consistent across multiple requests, especially for queries that return many pages of results.