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
Parameter | Type | Required | Default | Range |
---|---|---|---|---|
page | number | No | null | 1-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 topage=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:
- The
organic_results
array is empty - The number of results is less than the typical page size
Best Practices
- Start from page 1: Always start pagination from the first page and increment sequentially
- Handle empty results: Your application should gracefully handle cases where
organic_results
is empty
Error Cases
Error Case | Response |
---|---|
Page > 100 | Status 400 - Invalid page number |
Page < 1 | Status 400 - Invalid page number |
Page > available results | Status 200 with empty organic_results |
Non-numeric page | Status 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.