Google AI Mode Scraper API
Get the answers Google’s AI gives as JSON with one HTTP request. The Google AI Mode Scraper API returns the full AI Mode answer as structured text blocks, tables and lists, a Markdown version, and the list of sources it cites. A second endpoint returns the AI Overview block at the top of a normal search. This repo has a runnable Python, Node.js and cURL example for both and the real response each one returned.
What does a Google AI Mode scraper do?
A Google AI Mode scraper sends a question to Google’s AI Mode (and AI Overviews) and returns the generated answer with the web pages it cites, as structured data. Marketing and SEO teams use it to see whether their brand is mentioned or cited in AI answers (AEO / GEO), and to track how answers change over time and by country. You send a query, country and language and get JSON back.
Contents
Quick start
-
Create a free ScrapeBadger account. You get 1,000 free credits, no card needed.
-
Copy your API key from the dashboard and export it:
export SCRAPEBADGER_API_KEY="your_api_key"
-
Make your first request: ask Google AI Mode.
cURL
curl -sS --max-time 180 -G "https://scrapebadger.com/v1/google/ai-mode/search" \
-H "X-API-Key: $SCRAPEBADGER_API_KEY" \
--data-urlencode 'q=what is the best project management software for small teams' \
--data-urlencode 'gl=us' \
--data-urlencode 'hl=en' \
--data-urlencode 'include_html=false'
Python (pip install requests)
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/ai-mode/search",
headers={"X-API-Key": API_KEY},
params={
"q": "what is the best project management software for small teams",
"gl": "us",
"hl": "en",
"include_html": False,
},
timeout=180,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js (18+, no dependencies)
const params = new URLSearchParams({
q: 'what is the best project management software for small teams',
gl: 'us',
hl: 'en',
include_html: 'false',
});
const response = await fetch(`https://scrapebadger.com/v1/google/ai-mode/search?${params}`, {
headers: { 'X-API-Key': process.env.SCRAPEBADGER_API_KEY },
signal: AbortSignal.timeout(180000),
});
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(JSON.stringify(await response.json(), null, 2));
Every endpoint below has the same three versions in examples/, and the real response it returned is in output-samples/.
Endpoints
Base URL: https://scrapebadger.com. Authenticate with the X-API-Key header. Credits are charged only for successful requests.
Common parameters
| Parameter |
Description |
Default |
q |
The question or search query. |
|
gl |
Country (market) of the answer, e.g. us, gb, de. |
us |
hl |
Language code, e.g. en, de, fr. |
en |
Examples by endpoint
Each example prints the JSON response. The Python versions are below; Node.js and cURL versions are linked under each one.
Ask Google AI Mode
Get AI-generated search results from Google AI Mode.
GET /v1/google/ai-mode/search · Credits: 20 · Docs
| Parameter |
Required |
Type |
Default |
Description |
q |
Yes |
string |
|
Search query for AI-generated response |
gl |
|
string |
us |
Country (market) of the answer, e.g. us, gb, de. Defaults to the location’s country when location is set. |
hl |
|
string |
en |
Language code |
include_html |
|
boolean |
true |
Include the raw answer HTML (can be hundreds of KB). Set false when you only need text_blocks, markdown and references. |
location |
|
string |
|
Answer as if the user were here: a Google canonical location name (e.g. Wonju-si,Gangwon-do,South Korea), a Google criteria ID, or an unambiguous short name within gl. Use only one of location, uule, or lat/lon. |
uule |
|
string |
|
A Google UULE value in its w+ (canonical name) or j+ (coordinates) form. |
lat |
|
number |
|
Latitude of the user’s location (with lon). |
lon |
|
number |
|
Longitude of the user’s location (with lat). |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/ai-mode/search",
headers={"X-API-Key": API_KEY},
params={
"q": "what is the best project management software for small teams",
"gl": "us",
"hl": "en",
"include_html": False,
},
timeout=180,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js · cURL · Output sample (12 KB)
Get the AI Overview for a search
Get the AI Overview block Google renders inline at the top of a SERP. Google doesn’t show an AI Overview for every query; when it doesn’t, the endpoint answers 404 and the call isn’t billed.
GET /v1/google/ai-overview · Credits: 20
| Parameter |
Required |
Type |
Default |
Description |
q |
Yes |
string |
|
Search query — same shape as a Google Search query |
gl |
|
string |
us |
Country (market) of the answer, e.g. us, gb, de. Defaults to the location’s country when location is set. |
hl |
|
string |
en |
Language code |
import json
import os
import requests
API_KEY = os.environ["SCRAPEBADGER_API_KEY"]
response = requests.get(
"https://scrapebadger.com/v1/google/ai-overview",
headers={"X-API-Key": API_KEY},
params={
"q": "how does noise cancelling work",
"gl": "us",
"hl": "en",
},
timeout=120,
)
response.raise_for_status()
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
Node.js · cURL · Output sample (8 KB)
Example output
A real response from GET /v1/google/ai-mode/search, trimmed to the first items of each list. The full response is in output-samples/ai-mode.json.
{
"query": "what is the best project management software for small teams",
"markdown": "### AI Mode reply for what is the best project management software for small teams\n\nFor most small teams, [Highlight start] ClickUp or Trello are the best starting points [Highlight end] , depending on whether you want a…",
"references": [
{
"title": "Zapier",
"link": "https://zapier.com/blog/free-project-management-software/",
"snippet": null,
"source": null,
"favicon": null,
"thumbnail": null,
"index": 1
},
{
"title": "YouTube · Apetech Tech Tutorials",
"link": "https://www.youtube.com/watch?v=hCsvOzL1b8Y&vl=en-US&t=21",
"snippet": null,
"source": null,
"favicon": null,
"thumbnail": null,
"index": 2
}
]
}
Use it with AI agents (MCP)
ScrapeBadger runs a hosted MCP server, so Claude, Cursor, ChatGPT and other agents can call the Google AI Mode endpoints as tools, with no code.
- Claude (claude.ai or Claude Desktop): Settings → Connectors → Add custom connector →
https://mcp.scrapebadger.com/mcp, then sign in. No API key needed.
- Cursor, VS Code, Windsurf and other clients: add this server to your MCP config:
{
"mcpServers": {
"scrapebadger": {
"url": "https://mcp.scrapebadger.com/mcp?apis=google",
"headers": { "Authorization": "Bearer YOUR_SCRAPEBADGER_API_KEY" }
}
}
}
Then ask:
Ask Google AI Mode “what is the best CRM for startups” in the US and UK, and list which brands and sources each answer cites.
Setup guides for each client are in the MCP docs.
Use cases
Pricing
- Each endpoint’s credit cost is listed in the endpoints table.
- Only successful requests are billed. Blocked, empty and failed results cost nothing.
- New accounts get 1,000 free credits. After that, pay as you go or pick a monthly plan. Credits on pay-as-you-go never expire.
See ScrapeBadger pricing for the price per credit on each plan.
Errors
Errors come back as JSON with a detail field (and an error code on some).
| Status |
Meaning |
What to do |
400 / 422 |
A parameter is missing or invalid |
Check the parameter table for the endpoint |
401 |
Missing, invalid or expired API key |
Send the key in the X-API-Key header |
402 |
Out of credits |
Top up or upgrade in the dashboard |
403 |
The key can’t call this API, or the request came from an IP the key doesn’t allow |
Check the key’s scopes and IP allowlist |
404 |
The item, page or profile doesn’t exist (or is no longer public) |
Check the ID; not billed |
429 |
Over your account’s max concurrency |
Wait Retry-After (1 s) and retry; run fewer calls in parallel (concurrency) |
502 / 503 / 504 |
The target site failed or timed out on this attempt |
Not billed. Retry with backoff |
Long calls can run asynchronously: send Prefer: respond-async and poll the returned request_id (async requests).
FAQ
Is it legal to scrape Google AI Mode?
AI Mode answers and AI Overviews are shown publicly to anyone who searches, and collecting public data is generally lawful in most jurisdictions. Check the rules that apply to your use case and ask a lawyer if you’re unsure.
What's the difference between AI Mode and AI Overviews?
AI Overviews are the short AI summary at the top of some normal Google results. AI Mode is Google’s separate conversational search tab, with longer answers, tables and more sources. This repo covers both; see AI Mode vs AI Overviews vs Gemini.
How much does it cost?
Each request costs a fixed number of credits, shown in the endpoints table, and only successful requests are billed. You get 1,000 free credits when you sign up, then pay as you go or pick a plan on the pricing page.
Can I get answers for other countries and cities?
Yes. Set gl and hl for country and language, and location (or lat/lon) on AI Mode to get the answer a user in that city would see.
How fast is it?
AI Mode answers take longer than a normal search because Google generates them: about 15 seconds is typical. AI Overviews come back in about 3 seconds. Run calls in parallel up to your plan’s max concurrency, or send them asynchronously and poll the result.
Other languages
These examples use plain HTTP. Official SDKs wrap every endpoint with types and retries:
There is also a CLI (pip install scrapebadger-cli) and an n8n node.
Learn more
Disclaimer
ScrapeBadger is an independent tool and is not affiliated with, endorsed by, or sponsored by Google LLC or any of its subsidiaries or affiliates. “Google” is a trademark of Google LLC, used here only to describe the platform this scraper works with. This repository only covers publicly available data. You are responsible for how you use the data you collect and for following the laws that apply to you.
License
MIT. The examples are free to copy into your own projects.
评论