Get Google Autocomplete Suggestions in Python and Node
To get Google Autocomplete suggestions in Python or Node, send one GET request to the autocomplete endpoint with the text typed so far in q, then read the suggestions list from the JSON. Each suggestion carries its position, its text, a type, Google’s own relevance score, a url and a description. One call returns up to 15 suggestions.
Short answer: GET /api/google/autocomplete with q, language and country, and your key in the X-API-Key header. The price is per call, not per suggestion: $0.25 per 1K API calls at a $10 deposit, down to $0.15 at $1,250, which is $0.0167 to $0.0100 per 1,000 suggestions at a full answer of 15 — pay as you go, no subscription. New accounts get 10 free API calls shared across services. See pricing and the Google Autocomplete API page.
Autocomplete is the list Google shows under the search box while you type. As data it is a short list of phrases for any text typed so far, which keyword tools, content planners and search features lean on. Serpent is not affiliated with Google, and the suggestions are the ones Google offers for the text you send.
The call is small. The work is around it: reading the answer without trusting its length, handling an empty list, asking for more than one market, and turning one seed into many phrases without paying for repeats. The code below does each, in Python and Node.
What does the request look like?
It is a GET request to https://apiserpent.com/api/google/autocomplete with your key in an X-API-Key header. There are three parameters.
| Parameter | Required | Default | What it takes |
|---|---|---|---|
q | Yes | none | The text typed so far, up to 200 characters, for example iphone 16 |
language | No | en | A two-letter language code, for example en, de, pt |
country | No | us | A two-letter country code, for example us, gb, in, br |
From a terminal it is one command (example code, not run):
curl -G "https://apiserpent.com/api/google/autocomplete" \
--data-urlencode "q=iphone 16" -d language=en -d country=us \
-H "X-API-Key: sk_live_your_api_key"
The answer is JSON with five fields: query, language, country, suggestions and count. The saved answers also carry a success flag set to true, which none of the code below reads. The figure shows what those three saved answers held: the text sent, how many suggestions came back and of which type.
How do you read the answer in Python?
Install requests, put your key in place of the placeholder and use this. suggest() makes the call and returns the JSON. show() prints the answer, and it tests the suggestions list, not the HTTP status, because a text with nothing to offer is a different thing from a failed call.
import requests
API_KEY = "sk_live_your_api_key"
BASE = "https://apiserpent.com/api/google/autocomplete"
def suggest(q, language="en", country="us"):
params = {"q": q, "language": language, "country": country}
r = requests.get(BASE, params=params, headers={"X-API-Key": API_KEY}, timeout=60)
r.raise_for_status()
return r.json()
def show(q):
answer = suggest(q)
rows = answer.get("suggestions") or []
if not rows:
print(f"No suggestions came back for {q!r}")
return
print(f'{answer["query"]} | {answer["language"]}/{answer["country"]} | count: {answer["count"]}')
for s in rows:
print(f'{s["position"]:>2} {s["relevance"]:>5} {s["type"]:<8} {s["text"]}')
show("iphone 16")
The output below is from a saved sample answer for iphone 16 (en, us). I ran the code above with only the HTTP request swapped for the saved file, so the lines are what the snippet printed:
iphone 16 | en/us | count: 15
1 1150 query iphone 16 pro
2 1000 query iphone 16e
3 750 query iphone 16 pro max
4 601 query iphone 16 plus
5 600 query iphone 16 case
6 559 query iphone 16 colors
7 558 query iphone 16 price
8 557 query iphone 16 pro max case
9 556 query iphone 16 pro case
10 555 query iphone 16e case
11 554 query iphone 16 pink
12 553 query iphone 16 unlocked
13 552 query iphone 16e vs iphone 16
14 551 query iphone 16 pro max price
15 550 query iphone 16 release date
Notice that count is 15, the number of rows, and position 1 is the first suggestion Google ranks. And relevance runs from 1150 at position 1 down to 550 at position 15, and in none of the three saved answers does it rise as the position rises, which is what “a higher score is ranked higher” looks like in practice.
And in Node?
Node 18 and later includes fetch, so there is nothing to install. Save the client as client.mjs, so any other file can import it:
const API_KEY = "sk_live_your_api_key";
const BASE = "https://apiserpent.com/api/google/autocomplete";
export async function suggest(q, { language = "en", country = "us" } = {}) {
const params = new URLSearchParams({ q, language, country });
const res = await fetch(`${BASE}?${params}`, { headers: { "X-API-Key": API_KEY } });
if (res.ok === false) throw new Error(`HTTP ${res.status}`);
return res.json();
}
Then call.mjs prints the first five rows of the same answer, with the same empty-list check, and then looks at two more saved answers, which the next sections explain. Its second loop guards the list the same way:
import { suggest } from "./client.mjs";
async function show(q) {
const answer = await suggest(q);
const rows = answer.suggestions || [];
if (rows.length === 0) {
console.log(`No suggestions came back for "${q}"`);
return;
}
console.log(`${answer.query} | ${answer.language}/${answer.country} | count: ${answer.count}`);
for (const s of rows.slice(0, 5)) {
const rel = String(s.relevance).padStart(5);
console.log(`${String(s.position).padStart(2)} ${rel} ${s.type.padEnd(8)} ${s.text}`);
}
}
await show("iphone 16");
for (const q of ["what is 100% of 50", "amazon"]) {
console.log();
for (const s of (await suggest(q)).suggestions || []) {
if (s.type === "query") continue;
console.log(`${String(s.position).padStart(2)} ${s.type.padEnd(10)} text: ${s.text}`);
console.log(` url: ${s.url}`);
console.log(` description: ${s.description}`);
}
}
Printed output of the first part, again from the saved answer with only fetch swapped for the file:
iphone 16 | en/us | count: 15
1 1150 query iphone 16 pro
2 1000 query iphone 16e
3 750 query iphone 16 pro max
4 601 query iphone 16 plus
5 600 query iphone 16 case
What is in one suggestion?
Every suggestion has six fields: position, text, type, relevance, url and description. The figure sets the first row of the iphone 16 answer beside the navigation row from the amazon answer.
position counts from 1. text is the suggestion as Google shows it. type is query, navigation or calculator. relevance is Google’s own score for that suggestion, and a higher score is ranked higher. url is set for a navigation row, and description is then the page title. A query row has both null. In the saved calculator answer url is null and description is Calculator.
The score is not search volume. It orders the rows within one answer. This API returns no volume figure, and nothing in the answer says how many searches a phrase gets, so read the order and treat the number as a tie-breaker. I compared no scores across different texts, and I would not either.
What do navigation and calculator suggestions look like?
Most rows are query rows, which is what you want for a keyword list. A navigation row is a suggested web address, and a calculator row is an answer to arithmetic typed in the box. This continues the Python file and prints every row that is not a plain query:
for q in ("what is 100% of 50", "amazon"):
print()
for s in suggest(q).get("suggestions") or []:
if s["type"] == "query":
continue
print(f'{s["position"]:>2} {s["type"]:<10} text: {s["text"]}')
print(f' url: {s["url"]}')
print(f' description: {s["description"]}')
From the saved answers for what is 100% of 50 and amazon:
1 calculator text: = 50
url: None
description: Calculator
2 navigation text: https://www.amazon.com/
url: https://www.amazon.com/
description: Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more
The calculator row’s text is = 50, its description is Calculator and its url is null. The navigation row at position 2 of the amazon answer has an address and a page title. A calculator row is not a phrase to build a keyword list from, so the expansion code later in this post keeps only query rows. The Node file above already contains the same loop and prints the same rows, with null where Python prints None. The saved calculator answer holds 6 rows, not 15, which is a reason not to assume the length.
What should you do when the list is empty?
Write the code so that an empty suggestions list is a normal result for that text, not a crash. In show() above, answer.get("suggestions") or [] turns a missing or empty list into an empty one, and the if not rows branch prints a message and returns. In a loop, do the same: skip the text, note it in your own log and carry on with the next one. The expansion and market scripts below also wrap each call in try, so one failed call is logged and skipped instead of losing the run.
There is no empty answer among the saved samples, so I show no output for one. I did run the branch against a stand-in that replies with an empty list, and the code printed its own message. That tests the code, not the API. If a text comes back empty, try a shorter or plainer version before you decide there is nothing there.
How do you get other countries and languages?
country and language are two separate two-letter codes, both with defaults (us and en). Send a pair per call to see how the same text is completed in another market. This continues the Python file, asks for five markets and prints, for each, the suggestions that no other market returned:
MARKETS = [("us", "en"), ("gb", "en"), ("in", "en"), ("br", "pt"), ("de", "de")]
def by_market(q):
found = {}
for country, language in MARKETS:
try:
rows = suggest(q, language=language, country=country).get("suggestions") or []
except requests.RequestException as err:
print(f"skipped {country}/{language}: {err}")
continue
found[country] = [s["text"] for s in rows if s["type"] == "query"]
return found
def only_in(found):
"""For each country, the suggestions that no other country returned."""
out = {}
for country, texts in found.items():
others = {t for c, ts in found.items() if c != country for t in ts}
out[country] = [t for t in texts if t not in others]
return out
for country, texts in only_in(by_market("iphone 16")).items():
print(country, len(texts), texts[:3])
The Node version, saved as markets.mjs next to client.mjs:
import { suggest } from "./client.mjs";
const MARKETS = [["us", "en"], ["gb", "en"], ["in", "en"], ["br", "pt"], ["de", "de"]];
async function byMarket(q) {
const found = {};
for (const [country, language] of MARKETS) {
try {
const answer = await suggest(q, { language, country });
found[country] = (answer.suggestions || []).filter((s) => s.type === "query").map((s) => s.text);
} catch (err) {
console.log(`skipped ${country}/${language}: ${err.message}`);
}
}
return found;
}
// For each country, the suggestions that no other country returned.
function onlyIn(found) {
const out = {};
for (const [country, texts] of Object.entries(found)) {
const others = new Set(Object.entries(found).filter(([c]) => c !== country).flatMap(([, ts]) => ts));
out[country] = texts.filter((t) => !others.has(t));
}
return out;
}
for (const [country, texts] of Object.entries(onlyIn(await byMarket("iphone 16")))) {
console.log(country, texts.length, texts.slice(0, 3));
}
I show no output for these two: the saved answers are all en and us, so the stand-in could only check that each of the five requests was built correctly. Run it with your key and compare. Each market is its own call, so one text across five markets is five calls.
How do you expand a seed with letters and question words?
One text gives at most 15 phrases, so for a long list send many variations and merge the answers: the seed plus each letter a to z, a question word in front of the seed, and the seed plus a joiner such as vs or for. With the lists below that is 1 + 26 + 8 + 7 = 42 texts, so 42 calls per seed.
The code removes repeats by lower-cased text, keeps only query rows, and records which text produced each phrase. It continues the Python file:
import csv
import string
import time
QUESTION_WORDS = ["how", "what", "why", "can", "is", "does", "which", "where"]
JOINERS = ["vs", "or", "and", "for", "with", "without", "near"]
def variations(seed):
"""The seed itself, seed + a..z, question word + seed, seed + joiner: 42 texts."""
yield seed
for letter in string.ascii_lowercase:
yield f"{seed} {letter}"
for word in QUESTION_WORDS:
yield f"{word} {seed}"
for joiner in JOINERS:
yield f"{seed} {joiner}"
def expand(seed, language="en", country="us", pause=0.2):
rows, seen, calls, failed = [], set(), 0, []
for text in variations(seed):
calls += 1
try:
answer = suggest(text, language=language, country=country)
except requests.RequestException as err:
failed.append(text) # note it and carry on: one failed call must not lose the run
print(f"skipped {text!r}: {err}")
continue
for s in answer.get("suggestions") or []:
if s["type"] != "query":
continue # a web address or a calculator result is not a search phrase
key = s["text"].lower()
if key in seen:
continue
seen.add(key)
rows.append({
"seed": seed, "asked": text, "country": country, "language": language,
"position": s["position"], "relevance": s["relevance"], "suggestion": s["text"],
})
time.sleep(pause)
return rows, calls, failed
def save_csv(rows, path):
fields = ["seed", "asked", "country", "language", "position", "relevance", "suggestion"]
with open(path, "w", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=fields, lineterminator="\n")
writer.writeheader()
writer.writerows(rows)
rows, calls, failed = expand("iphone 16")
save_csv(rows, "suggestions.csv")
print(f"{calls} calls, {len(failed)} failed, {len(rows)} rows written to suggestions.csv")
The same in Node, saved as expand.mjs:
import { writeFileSync } from "node:fs";
import { suggest } from "./client.mjs";
const QUESTION_WORDS = ["how", "what", "why", "can", "is", "does", "which", "where"];
const JOINERS = ["vs", "or", "and", "for", "with", "without", "near"];
const LETTERS = "abcdefghijklmnopqrstuvwxyz".split("");
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
function variations(seed) {
return [
seed,
...LETTERS.map((l) => `${seed} ${l}`),
...QUESTION_WORDS.map((w) => `${w} ${seed}`),
...JOINERS.map((j) => `${seed} ${j}`),
];
}
async function expand(seed, { language = "en", country = "us", pause = 200 } = {}) {
const rows = [];
const seen = new Set();
const failed = [];
let calls = 0;
for (const text of variations(seed)) {
calls += 1;
let answer;
try {
answer = await suggest(text, { language, country });
} catch (err) {
failed.push(text); // note it and carry on: one failed call must not lose the run
console.log(`skipped "${text}": ${err.message}`);
continue;
}
for (const s of answer.suggestions || []) {
if (s.type !== "query") continue; // a web address or a calculator result is not a search phrase
const key = s.text.toLowerCase();
if (seen.has(key)) continue;
seen.add(key);
rows.push({ seed, asked: text, country, language, position: s.position, relevance: s.relevance, suggestion: s.text });
}
await sleep(pause);
}
return { rows, calls, failed };
}
const cell = (v) => {
const s = String(v);
return /[",\n]/.test(s) ? `"${s.replaceAll('"', '""')}"` : s;
};
function saveCsv(rows, path) {
const fields = ["seed", "asked", "country", "language", "position", "relevance", "suggestion"];
const lines = [fields.join(","), ...rows.map((r) => fields.map((f) => cell(r[f])).join(","))];
writeFileSync(path, lines.join("\n") + "\n");
}
const { rows, calls, failed } = await expand("iphone 16");
saveCsv(rows, "suggestions.csv");
console.log(`${calls} calls, ${failed.length} failed, ${rows.length} rows written to suggestions.csv`);
Printed by the Python version, and by the Node version in the same words. A failed call is counted in failed; none failed here:
42 calls, 0 failed, 15 rows written to suggestions.csv
Read that line with care. The saved file holds an answer only for iphone 16 itself. For the other 41 texts the stand-in had nothing saved and replied with an empty list, so the 15 rows are the saved answer’s rows and nothing more. A real run adds whatever the other texts return, and I do not know how many that is. What the run does show is the code: 42 requests, each built correctly.
The question words and joiners are starting points. Whether “how iphone 16” returns anything useful is for your run to say, so swap in the ones that fit your topic and keep the budget in mind: 42 calls per seed is cheap for one seed and a real number for ten thousand.
How do you save the suggestions to a CSV?
The last lines of the expansion code write suggestions.csv with one row per phrase: the seed, the text that produced it, the country and language, the position, the relevance score and the suggestion. Both versions wrote the same file in my run (I compared them byte for byte). These are its first four lines, from the saved answer:
seed,asked,country,language,position,relevance,suggestion
iphone 16,iphone 16,us,en,1,1150,iphone 16 pro
iphone 16,iphone 16,us,en,2,1000,iphone 16e
iphone 16,iphone 16,us,en,3,750,iphone 16 pro max
Keep asked, country and language in every row: they let you group, filter and tell runs apart when you merge files. Keep position as a record of where Google put the phrase when you asked, not as a key.
What does a run cost?
The price is per call, not per suggestion: $0.25 per 1K API calls at a $10 deposit, down to $0.15 at $1,250, pay as you go with no subscription. The per-suggestion column is the price divided by 15, a full answer; a shorter answer works out dearer per suggestion. See the pricing page for how deposit size sets the rate.
| Tier | Deposit | Per 1K API calls | Per 1,000 suggestions | One seed (42 calls) |
|---|---|---|---|---|
| Default | $10 | $0.25 | $0.0167 | $0.0105 |
| Growth | $100 | $0.22 | $0.0147 | $0.0092 |
| Scale | $500 | $0.19 | $0.0127 | $0.0080 |
| Enterprise | $1,000 | $0.17 | $0.0113 | $0.0071 |
| Enterprise Plus | $1,250 | $0.15 | $0.0100 | $0.0063 |
Among the sellers whose pages I read on 1 December 2026 and that state a per-call price (DataForSEO from $0.60 per 1K, the Apify actor scrape.badger from $0.50), $0.25 is the cheapest price. The price comparison has the detail. New accounts get 10 free API calls shared across services.
Which mistakes come up most often?
- Reading the score as search volume. Relevance orders one answer. It does not count searches, and this API returns no volume figure.
- Assuming 15 rows. One saved answer held 6. Use
countor the length of the list. - Treating every row as a search phrase. A navigation row is an address and a calculator row is a sum. Filter on
type. - Using
positionas an id. It describes one answer. Key phrases by their lower-cased text. - Forgetting the defaults. Without
languageandcountryyou getenandus, one market.qtakes up to 200 characters. - Expanding blindly. 42 calls per seed adds up across thousands of seeds, and repeats are possible, so de-duplicate as the code does.
For what to do with a pile of suggestions once you have it, read Google Autocomplete data for keyword research. The Google Autocomplete API page and the docs hold the reference.
How we checked this
Code. I ran every snippet on Python 3.15.2 and Node 26.5.0 against three saved sample answers, with only the network call replaced by a stand-in. It returns the saved answer for iphone 16, what is 100% of 50 or amazon with language en and country us, and an empty list for anything else, and it checks the address, the X-API-Key header and the parameters of every request. I also checked each file with python3 -m py_compile and node --check. The output in this post is what the snippets printed, and the scripts and outputs are saved with this post’s evidence.
Prices. Our figures are per 1K API calls, from the Google Autocomplete row of the pricing page, which also gives the deposit sizes. The per-suggestion and per-seed figures are arithmetic from cost-calc.js, which I ran. I read the DataForSEO pricing page and the scrape.badger Apify page on 1 December 2026.
What I could not verify:
- I did not call the endpoint, so no answer here comes from a call to it, and I cannot say how long a call takes or how often a text comes back empty.
- No saved answer exists for another country or language, or for an empty list, so those parts are tested against the stand-in only.
- What the 41 letter, question and joiner texts return for any seed is not shown.
- The SerpApi, Scrapingdog and Serper pages I read did not state what one autocomplete call costs, so I give no per-call price for them. The curl line was not run.
Try one call before you build the loop
Serpent’s Google Autocomplete API costs $0.25 per 1K API calls at a $10 deposit — pay as you go, no subscription. New accounts get 10 free API calls shared across services.
Get Your Free API KeyExplore: Google Autocomplete API · Docs · Pricing
FAQ
How do I get Google Autocomplete suggestions in Python?
Send a GET request to https://apiserpent.com/api/google/autocomplete with the text typed so far as q and your key in the X-API-Key header, then read the JSON. The suggestions list holds up to 15 rows, each with a position, the text, a type, Google’s relevance score, a url and a description. The url is set for a navigation row, and the description is then the page title. Check the list is not empty before you save anything.
How many suggestions does one call return?
Up to 15. The saved sample answers held 15 for iphone 16, 6 for what is 100% of 50 and 15 for amazon, so use the count field or the length of the list rather than assuming 15. The price is per call, not per suggestion.
How do I get suggestions for another country or language?
Send country and language as two-letter codes, for example country=gb&language=en or country=br&language=pt. They default to us and en. The two are separate, so you can ask for one language in several countries. Each pair is its own call, so five markets for one text cost five calls.
How do I get a long list of suggestions for one keyword?
Expand the seed into many short texts and call once for each: the seed itself, the seed plus each letter a to z, a question word before the seed, and a joiner such as vs or for after it. The script in this post sends 42 texts per seed, so 42 calls, then removes repeats and keeps only the query rows. At $0.25 per 1K API calls that is about $0.0105 per seed.
Is the relevance score the same as search volume?
No. Relevance is Google’s own score for that suggestion within one answer, and a higher score is ranked higher. It does not say how many searches a phrase gets, and this API returns no search-volume figure. Use it to order the rows of one answer, not to compare phrases across answers.
What does the Google Autocomplete API cost?
$0.25 per 1K API calls at a $10 deposit, down to $0.15 per 1K API calls at $1,250, pay as you go with no subscription. The price is per call, so at a full answer of 15 suggestions it works out at $0.0167 to $0.0100 per 1,000 suggestions. New accounts get 10 free API calls shared across services.
Sources
Seller pages (read 1 December 2026):
Serpent data in this post: three saved sample answers, the checks listed under “How we checked this”, and the pricing page.




