Google AI Mode
The Google AI Mode API endpoint fetches response data from a results page of a Google AI Mode prompt. Results can be returned in raw HTML format or as a structured JSON format.
curl --request GET \
--url "https://api.scraperapi.com/structured/google/aimode?api_key=API_KEY&\
query=QUERY&country_code=COUNTRY_CODE&tld=TLD"import requests
payload = {
'api_key': 'API_KEY',
'query': 'QUERY',
'country_code': 'COUNTRY_CODE',
'tld': 'TLD'
}
r = requests.get('https://api.scraperapi.com/structured/google/aimode',params=payload)
print(r.text)import fetch from 'node-fetch';
fetch(
'https://api.scraperapi.com/structured/google/aimode?api_key=API_KEY&query=QUERY&country_code=COUNTRY_CODE&tld=TLD'
)
.then(response => response.json())
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});Async Request
curl -s -X POST \
"https://async.scraperapi.com/structured/google/ai_mode" \
-H "Content-Type: application/json" \
-d '{
"apiKey": "API_KEY",
"query": "PROMPT_TEXT",
"country_code": "COUNTRY_CODE",
"tld": "TLD"
}'import requests
url = "https://async.scraperapi.com/structured/google/ai_mode"
headers = {
"Content-Type": "application/json"
}
data = {
"apiKey": "API_KEY",
"query": "QUERY",
"country_code": "COUNTRY_CODE",
"tld": "TLD"
}
response = requests.post(url, json=data, headers=headers)
print(response.text)Note: If you want to send multiple prompts at once use queries instead of query.
Example: "queries": ["PROMPT_TEXT1", "PROMPT_TEXT2"],
Async Response
After the job(s) finish, you will find the response payload by polling the statusURL.
Supported Parameters
API_KEY (required)
Your API Key.
QUERY (query or url required)
The prompt to send to Google AI Mode.
URL (query or url required)
The full Google Search URL, passed exactly as provided. It must use a google.* domain and include the udm=50 query parameter.
TLD
Country of Google domain to scrape. This is an optional argument and defaults to “com” (google.com). Valid values include: com (google.com) co.uk (google.co.uk) ca (google.ca) de (google.de) es (google.es) fr (google.fr) it (google.it) co.jp (google.co.jp) in (google.in) cn (google.cn) com.sg (google.com.sg) com.mx (google.com.mx) ae (google.ae) com.br (google.com.br) nl (google.nl) com.au (google.com.au) com.tr (google.com.tr) sa (google.sa) se (google.se) pl (google.pl)
COUNTRY_CODE
Valid values are two letter country codes for which we offer Geo Targeting (e.g. “au”, “es”, “it”, etc.). Where a Google domain needs to be scraped from another country (e.g. scraping google.com from Canada), both TLD and COUNTRY_CODE parameters must be specified.
OUTPUT_FORMAT
json returns parsed structured data (default). html returns raw HTML.
INCLUDE_HTML
Determines whether raw HTML is included in the response (this can increase the size of the response). Can be set to true or false (default).
Google parameters supported by this endpoint
HL
Host Language. For example: DE.
GL
Boosts matches whose country of origin matches the parameter value. For example: DE.
UULE
Set a region for a search. For example: w+CAIQICINUGFyaXMsIEZyYW5jZQ. You can find an online UULE generator here.
START
Set the starting offset in the result list. When start=10 set the first element in the result list will be the 10th search result. (meaning it starts with page 2 of results if the "num" is 10).
NEAR
Biases search results toward a specified location.
TBS
Limits results to a specific time range. For example: tbs=d returns results from the past day. Possible values: tbs=h - Hour
tbs=d - Day
tbs=w - Week
tbs=m - Month
tbs=y - Year
GWS
Value mapped internally to the gws_rd Google query parameter.
IE
Input character encoding (for example UTF-8).
OE
Output character encoding (for example UTF-8).
JSON Response
Field Reference
query
string
yes
Echoed prompt
url
string | null
yes
Result/thread URL
model
string | null
yes
Best-effort. null when not surfaced
answer
string (Markdown)
yes
The answer body
sources[]
array of object
yes (may be empty)
{ title, url, domain, snippet }
related_queries[]
array of string
yes (may be empty)
Follow-up suggestions
All fields are always present in the JSON (empty array or null rather than omitted).
Specifics
model
Omittedentirely for Google AI Mode. Google never exposes a model in the AI Mode results page, so the field is left out rather than shipped as a permanentnull.
sources
Present in the response.
snippet
domain is normalized to a bare hostname (www. stripped) across all engines.
Pricing
Google AI Mode queries run on ScraperAPI's standard credit system.
Request Type
Credits Charged
Any Parameter
25
Last updated

