DEV Community

Elowen
Elowen

Posted on

How to Get Google Search Results as JSON

Google search results are useful for many products and workflows: SEO tools, keyword research, content monitoring, market research, AI agents, and ranking trackers.

But Google search result pages are not easy to use directly in software. The HTML changes often, results differ by country and language, and manually parsing search pages can become fragile very quickly.

A SERP API solves this problem by returning Google search results in a structured JSON format.

In this article, we will walk through how to get Google search results as JSON using TalorData SERP API.

What We Are Building

We will send a Google search query to a SERP API and receive a JSON response that contains structured search result data.

For example, instead of manually opening Google and searching:

best ai resume builder
Enter fullscreen mode Exit fullscreen mode

We can send the keyword to an API and get results like:

{
  "organic_results": [
    {
      "title": "Best AI Resume Builder",
      "link": "https://example.com",
      "snippet": "Create a professional resume with AI..."
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

This makes the data easier to store, analyze, compare, or use inside an application.

Use Cases

Getting Google search results as JSON is useful when you need to:

  • Track keyword rankings
  • Monitor competitors in search results
  • Analyze SEO opportunities
  • Collect People Also Ask questions
  • Check whether ads appear for a keyword
  • Build AI or RAG workflows with live search context
  • Compare search results across different countries or languages

API Request Example

TalorData SERP API supports Google search requests and can return structured JSON data.

Here is a basic curl example:

curl -X POST "https://serpapi.talordata.net/serp/v1/request" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "engine=google" \
  -d "q=best ai resume builder" \
  -d "json=2"
Enter fullscreen mode Exit fullscreen mode

Replace YOUR_API_KEY with your own TalorData API key.

You can register a TalorData account and get an API key from the official website:

https://www.talordata.com/

Request Parameters

The basic request contains three important fields:

Parameter Meaning
engine The search engine to use. In this example, google.
q The keyword or search query.
json The response format option. json=2 returns structured JSON.

For a simple Google search JSON request, this is enough to start.

Python Example

Here is a simple Python script that sends a Google search query and prints the JSON response.

import requests
import json

API_KEY = "YOUR_API_KEY"

url = "https://serpapi.talordata.net/serp/v1/request"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/x-www-form-urlencoded",
}

data = {
    "engine": "google",
    "q": "best ai resume builder",
    "json": "2",
}

response = requests.post(url, headers=headers, data=data, timeout=30)
response.raise_for_status()

result = response.json()

print(json.dumps(result, indent=2, ensure_ascii=False))
Enter fullscreen mode Exit fullscreen mode

Run the script:

python get_google_results.py
Enter fullscreen mode Exit fullscreen mode

If the request succeeds, you will receive Google search results in JSON format.

Extract Organic Results

Most applications do not need the entire JSON response. Usually, you only need specific fields, such as organic results.

Here is an example:

organic_results = result.get("organic_results", [])

for index, item in enumerate(organic_results, start=1):
    title = item.get("title")
    link = item.get("link")
    snippet = item.get("snippet")

    print(index, title)
    print(link)
    print(snippet)
    print()
Enter fullscreen mode Exit fullscreen mode

Example output:

1 Best AI Resume Builder
https://example.com
Create a professional resume with AI...

2 Free Resume Builder Online
https://example.org
Build a resume online for free...
Enter fullscreen mode Exit fullscreen mode

Now the search results are no longer just a web page. They are structured data that your program can process.

Save Results to a CSV File

If you want to analyze search results in Excel, Google Sheets, or a database, you can export the data to CSV.

import csv

organic_results = result.get("organic_results", [])

with open("google_results.csv", "w", newline="", encoding="utf-8-sig") as f:
    writer = csv.writer(f)
    writer.writerow(["position", "title", "link", "snippet"])

    for index, item in enumerate(organic_results, start=1):
        writer.writerow([
            index,
            item.get("title", ""),
            item.get("link", ""),
            item.get("snippet", ""),
        ])
Enter fullscreen mode Exit fullscreen mode

After running the script, you will get a file:

google_results.csv
Enter fullscreen mode Exit fullscreen mode

The CSV may look like this:

position title link snippet
1 Best AI Resume Builder https://example.com Create a professional resume with AI...
2 Free Resume Builder Online https://example.org Build a resume online for free...

Full Python Script

Here is the complete example:

import requests
import json
import csv

API_KEY = "YOUR_API_KEY"

url = "https://serpapi.talordata.net/serp/v1/request"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/x-www-form-urlencoded",
}

data = {
    "engine": "google",
    "q": "best ai resume builder",
    "json": "2",
}

response = requests.post(url, headers=headers, data=data, timeout=30)
response.raise_for_status()

result = response.json()

print(json.dumps(result, indent=2, ensure_ascii=False))

organic_results = result.get("organic_results", [])

with open("google_results.csv", "w", newline="", encoding="utf-8-sig") as f:
    writer = csv.writer(f)
    writer.writerow(["position", "title", "link", "snippet"])

    for index, item in enumerate(organic_results, start=1):
        writer.writerow([
            index,
            item.get("title", ""),
            item.get("link", ""),
            item.get("snippet", ""),
        ])

print("Saved results to google_results.csv")
Enter fullscreen mode Exit fullscreen mode

What You Can Do Next

Once you can get Google search results as JSON, you can build more useful workflows on top of it.

For example:

  • Run the same keyword every day and track ranking changes
  • Compare search results across multiple countries
  • Collect the top ranking domains for a keyword group
  • Detect whether ads appear for commercial keywords
  • Extract People Also Ask questions for content ideas
  • Export search results into a dashboard or database

Common Issues

1. Invalid API Key

If the API key is wrong or missing, the request may fail with an authentication error.

Check this line:

API_KEY = "YOUR_API_KEY"
Enter fullscreen mode Exit fullscreen mode

Make sure it contains your real API key.

2. Empty Results

If the response does not contain organic results, check:

  • Whether the keyword is valid
  • Whether the request succeeded
  • Whether the response field name matches your parsing logic
  • Whether the selected search engine supports the requested query

3. Timeout

If the request times out, increase the timeout value:

response = requests.post(url, headers=headers, data=data, timeout=60)
Enter fullscreen mode Exit fullscreen mode

Conclusion

Using a SERP API is one of the simplest ways to get Google search results as JSON.

Instead of scraping and parsing Google result pages manually, you can send a search query to an API and receive structured data that is easier to use in software.

With this basic workflow, you can build ranking trackers, SEO research tools, competitor monitoring systems, content research workflows, and search-based AI applications.

Top comments (0)