If you have ever tried to build a keyword research tool or an autocomplete search feature, you probably first reached for the Google Places API. I have seen countless engineering teams waste development budget on Google Maps credits only to realize that the Places API is strictly limited to physical addresses and local businesses—not organic web search predictions.
Since there is no official, documented public API for Google Search suggestions, we have to look under the hood at how browsers fetch these predictions in real-time.
The Undocumented Autocomplete Endpoint
When you type into the Chrome address bar, the browser sends HTTP GET requests to an undocumented endpoint. We can query this exact same pipeline:
https://suggestqueries.google.com/complete/search?client=chrome&q={query}&hl={lang}&gl={country}
Using the query parameter client=chrome is critical. It forces Google’s servers to return a clean, nested JSON array. If you use older values like toolbar or youtube, you will get back legacy XML payloads that require heavy parsing libraries and waste CPU cycles.
| Parameter | Required | Example | Role in Request Pipeline |
|---|---|---|---|
client |
Yes | chrome |
Forces JSON format instead of XML |
q |
Yes | docker deploy |
The raw partial search string |
hl |
No | en |
Language code for localization |
gl |
No | us |
Country code for geo-targeting |
Building a Basic Python Scraper
Here is a lightweight Python implementation to query this endpoint. In a production environment, you must route requests through rotating residential proxies and mimic browser-level headers.
import requests
import json
def fetch_suggestions(query: str, lang="en", country="us") -> list:
url = "https://suggestqueries.google.com/complete/search"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
"Accept": "*/*",
"Referer": "https://www.google.com/"
}
params = {
"client": "chrome",
"q": query,
"hl": lang,
"gl": country
}
# Configure rotating residential proxies to bypass blocks
proxies = {
"http": "http://username:password@proxy.example.com:8000",
"https": "http://username:password@proxy.example.com:8000"
}
try:
response = requests.get(url, headers=headers, params=params, proxies=proxies, timeout=5)
if response.status_code == 200:
raw_data = json.loads(response.text)
# The suggestion strings live at index 1 of the returned list
return raw_data[1]
elif response.status_code == 429:
print("Block detected: HTTP 429 Too Many Requests")
return []
except Exception as e:
print(f"Request failed: {str(e)}")
return []
# Example execution
if __name__ == "__main__":
print(fetch_suggestions("kubernetes cluster"))
The Engineering Hurdle: JA3 Fingerprinting & HTTP 429s
If you deploy this script on a VPS (like AWS or DigitalOcean) without proxies, Google's firewalls will block your IP within a few dozen requests.
Even if you rotate standard HTTP user-agents, Google uses JA3/TLS Fingerprinting to analyze the low-level cryptographic handshake of your HTTP library (such as Python requests or Node.js axios). If the TLS signature does not match a real browser version, the connection is instantly throttled.
To bypass this at scale, you have two options:
- Use tools like
curl-impersonateto spoof TLS signatures. - Maintain a pool of premium rotating residential proxies (which generally cost between $3 and $15 per gigabyte).
Scaling and Managed Alternatives
To build a deep keyword discovery engine, you can use a wildcard expansion technique. Programmatically loop through your seed keyword appended with letters "a" through "z" (e.g., seed + a, seed + b) or prepended with question modifiers ("how to...", "why...").
For large-scale, production-ready platforms, managing your own proxy infrastructure and TLS bypasses quickly becomes an engineering money pit. If you want to stop debugging broken scrapers and paying expensive residential proxy invoices, switching to a managed API provider like SerpApi is highly recommended. It handles the proxy rotation, localization, and TLS fingerprinting under a flat-rate billing model, returning clean JSON without the maintenance overhead.
Originally published at How to get Google search autocomplete suggestions via API
Top comments (0)