DEV Community

Cover image for Google Autocomplete API: Turn Type-Ahead Suggestions into JSON in 2026 (Python, MCP, No-Code)
Truffle Pig Data
Truffle Pig Data

Posted on

Google Autocomplete API: Turn Type-Ahead Suggestions into JSON in 2026 (Python, MCP, No-Code)

Type half a query into Google and the dropdown finishes your sentence: ranked, localized, and drawn from what people actually search. I think of it as Google publishing its own query logs, ten lines at a time, and there is no clean official way to collect it. This post covers the DIY route, its potholes, and the Google Autocomplete API on Apify, which returns the ranked suggestion list for any batch of partial queries as JSON.

Disclosure: the Apify links in this post are affiliate links. If you run the Actor, I may earn a referral commission at no extra cost to you.

Is there an official Google Autocomplete API?

Not for web search. Google Maps Platform sells Places Autocomplete, which completes place names inside a maps product, and that is a different job. For general search suggestions there is only an undocumented endpoint that returns quirky JSONP, throttles you at volume, and can change any day. So in practice a Google Autocomplete API means a scraper consumed as an API: partial queries in, ranked suggestions out.

What the Google Autocomplete API returns

The Google Autocomplete API returns the ranked suggestion list for each partial query as structured JSON: one record per suggestion, linking the source query, the suggestion's rank, and the suggested text, localized by country and language.

Data point Example Notes
Input query coffee near the partial query you sent
Suggested text coffee near me open now one record per suggestion
Rank 1 position in the dropdown
Country (gl) us two-letter localization code
Language (hl) en interface language for suggestions

Who this is for

SEO and PPC people expanding seed keywords into real phrases, builders resolving vague place queries before a Maps or Places lookup, and agent developers who want autocomplete as a disambiguation tool.

The manual way, and where it breaks

Manual collection is an incognito window and a spreadsheet: type each seed, transcribe ten suggestions, switch your VPN to change country, repeat. The script version hits the unofficial suggest endpoint, and it works right up until it does not: undocumented parameters, JSONP wrappers to strip, localization that follows your IP instead of your settings, and throttling once you send real volume. Neither version leaves you with anything stable enough to build on.

The faster way: run the Google Autocomplete API

Apify Console

  1. Open the Google Autocomplete API and click Try for free.
  2. Add partial queries under queries, like coffee near, and set gl and hl if you want another market.
  3. Run it and export the suggestions as JSON or CSV.

REST

curl -X POST "https://api.apify.com/v2/acts/johnvc~google-autocomplete-api/runs?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "queries": ["coffee near"], "gl": "us", "hl": "en" }'
Enter fullscreen mode Exit fullscreen mode

Full endpoint reference: the Apify API docs.

Expand keywords in Python

from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")

run = client.actor("johnvc/google-autocomplete-api").call(
    run_input={
        "queries": ["coffee near", "best pizza in"],
        "gl": "us",
        "hl": "en",
    }
)

for suggestion in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(suggestion)
Enter fullscreen mode Exit fullscreen mode

Every record ties back to its input query with a rank, so grouping by seed and sorting by rank rebuilds each dropdown exactly.

Get suggestions for any keyword

Get Google search suggestions for any keyword is the plain starting point: one seed, the ranked list back.

Mine long-tail keyword ideas

Get long tail keyword ideas from Google autocomplete expands seeds into the specific phrases people type, which is where low-competition content lives.

Pull question keywords

Get question keywords from Google autocomplete harvests question-format phrases, ready-made for FAQ sections and content planning.

Find negative keywords for Google Ads

Find negative keywords for Google Ads surfaces suggestions that reveal intents you do not want to pay for, like free, cheap, or DIY variants.

Keyword research data as JSON

Get keyword research data as JSON from Google is the spreadsheet-ready version of the whole loop.

It speaks Chinese too

Google search suggestions in Chinese and Chinese long-tail keywords run the same pattern for Chinese-language markets.

Use it from Claude via MCP

Ask Claude what people search after "best crm for" and, with the Actor connected as an MCP tool through Apify, it fetches the live list instead of guessing. The same tool works in Claude Code and Cursor for agent-driven query expansion, and claude.ai is where to pick up Claude if you need it.

FAQ about scraping Google Autocomplete

How much does the Google Autocomplete scraper cost, and is anything free?

Billing is 0.2 cents per suggestion returned on the free tier, so a seed returning ten suggestions costs about two cents. New Apify accounts carry free platform credit, which means early keyword batches usually cost nothing out of pocket.

Why not scrape Google's suggest endpoint myself instead of using a hosted scraper?

For a weekend test, go ahead; that endpoint is how many of us started. For anything recurring you inherit undocumented parameters, response-format changes, and throttling, and the hosted version trades a fraction of a cent per suggestion for never owning that.

Can the scraper localize suggestions by country and language?

Yes: gl sets the country and hl the language for each run, so you can pull the same seeds for the US, Germany, and Japan and diff the dropdowns.

Does the scraper work as an MCP tool in Claude or Cursor?

Yes, via the Apify MCP server it registers as a callable tool, which turns autocomplete into a live lookup step inside agent workflows.

Can I schedule the scraper to keep keyword lists fresh?

Yes, recurring runs are the intended pattern: schedule a task with your seed list and accumulate suggestion history for trend analysis. Set it up from the Google Autocomplete API.

What won't an autocomplete scraper tell you?

Search volume or difficulty. A suggestion means Google predicts the phrase, not how often people search it, so pair the output with a volume source before betting a content calendar on it.

More from Truffle Pig Data

Adjacent search-data Actors: the Google AI Overview API for what Google's AI answers say, the Google Forums Search API for discussion results, and the DuckDuckGo SERP Scraper for rankings on the private-search side.

Wrapping up

The dropdown was always the most honest keyword data Google shows; now it exports. Feed a few seeds to the Google Autocomplete API and see what your customers type.

Top comments (0)