The Google Search SERP API enables seamless extraction of search engine results from Google, providing structured search results with rich metadata. This API allows users to retrieve search rankings, advertisements, organic results, and other relevant details efficiently, making it an essential tool for SEO analysis, market research, and competitive intelligence.

Key Features

  • Retrieve the total number of search results for a given query.
  • Extract organic search result details, including:
    • Title, description, and URL.
    • Ranking position in the search results.
  • Capture paid advertisements (Google Ads) when present.
  • Support for pagination to navigate multiple pages of search results.
  • Obtain localized search results by specifying language and region settings.

Supported Query Parameters

PARAMETERTYPEDEFAULTDESCRIPTION
urlstring <uri>The full Google Search URL for which results should be extracted. Example: https://www.google.com/search?q=web+scraping.
tldstring.comThe top-level domain of the Google website. Supported examples: .com, .ca, .co.uk, …
countrystringThe originating country for the search. Example: country=es.

How to Use

To extract Google search results, make a request to the API endpoint with your desired query parameters:

https://serp.api.zenrows.com/v1/targets/google/search?url={url}&apikey=YOUR_ZENROWS_API_KEY

Code Examples

# pip install requests
import requests
import urllib.parse

query = "web scraping"  # Example query
encoded_query = urllib.parse.quote(query)
api_endpoint = f"https://serp.api.zenrows.com/v1/targets/google/search/{encoded_query}"
params = {
    "apikey": "YOUR_ZENROWS_API_KEY",
}
response = requests.get(api_endpoint, params=params)
print(response.text)
Note: should be URL-encoded.

Response Example

{
  "total_results": 125000000,
  "organic_results": [
    {
      "title": "What is Web Scraping? A Beginner's Guide - ZenRows",
      "link": "https://www.zenrows.com/web-scraping-guide",
      "snippet": "Learn the fundamentals of web scraping, how it works, and its applications."
    },
    {
      "title": "Best Web Scraping Tools in 2024 - Comparison",
      "link": "https://www.example.com/best-web-scraping-tools",
      "snippet": "A detailed comparison of the top web scraping tools available today."
    }
  ],
  "ad_results": [
    {
      "title": "Top Web Scraping API - Free Trial Available",
      "link": "https://www.exampleads.com/webscraping",
      "snippet": "Get structured data from any website effortlessly with our advanced API."
    }
  ]
}

Troubleshooting and FAQs