For years the Custom Search JSON API was how most projects got Google results as JSON the official way: a key, an engine ID, 100 free queries a day. Google has now closed it to new customers, and its pricing section speaks of "the service discontinuation on January 1, 2027". If your app, script or agent calls googleapis.com/customsearch/v1, it needs a new source within weeks.
Which source depends on what your engine searched. If it searched your own site, Google's suggested replacement is probably right and we say so below. If you used it as a general Google search API, Google offers no self-serve successor, and a search API such as ScrapingBot is the practical route. This page covers both, with measurements from December 1, 2026.
How we compared
ScrapingBot is our product. Facts about Google's API come from its own Custom Search JSON API overview (the notice and the pricing), the cse.list reference, the response reference and Google Cloud's pricing page for Vertex AI Search, all read on December 1, 2026. We could not run the JSON API side by side: it no longer takes new customers. The ScrapingBot numbers are from more than 200 searches we ran that day.
What Google has said
The notice sits at the top of the JSON API's overview page. In Google's words:
From Google's Custom Search JSON API overview, read December 1, 2026
"The Custom Search JSON API is closed to new customers. Vertex AI Search is a favorable alternative for searching up to 50 domains. Alternatively, if your use case necessitates full web search, contact us to express your interest in and get more information about our full web search solution. Existing Custom Search JSON API customers have until January 1, 2027 to transition to an alternative solution."
So there are two official paths. Vertex AI Search is a Google Cloud product that indexes sites you name and answers queries over them; its pricing page, which now calls the product Agent Search, lists website search under the Enterprise edition at $4.00 per 1,000 queries, with 10,000 queries per account per month at no cost and index storage free up to 10 GiB. The other path, for searching the whole web, is a contact form.
The short version
Pick ScrapingBot if
site: operators, 12 in one query in our test.
cse.py below keeps your result-handling code as it is.
Pick Vertex AI Search if
The JSON API and ScrapingBot at a glance
| Custom Search JSON API | ScrapingBot | |
|---|---|---|
| Status | Closed to new customers; ends January 1, 2027 | Open: sign up and call |
| What it searches | The sites in your Programmable Search Engine | Google itself: the results google.com shows for the query |
| Price | $5 per 1,000 queries | 10 credits a search: $1.82 per 1,000 on Starter, $0.91 on Startup, $0.76 on Pro |
| Free allowance | 100 queries a day | 100 credits once: 10 searches, no card |
| Daily cap | 10,000 queries | None: your credits, and your plan's concurrency (10 on Starter) |
| Results per page | Up to 10 (num) | Google's page: 5 to 10 in our test, 8 at the median |
| Results per query | 100 at most | 85 to 100 unique results before the pages ran out |
| Total result count | searchInformation.totalResults | Not returned |
| Beyond web results | Image search, pagemap metadata, promotions, spelling | People also ask and related searches; images, news, videos, shopping and maps as separate endpoints |
| Failed calls | Not compared | Refunded |
Per-1,000 figures for ScrapingBot: $49.99 ÷ 275,000 credits × 10 credits × 1,000 = $1.82 on Starter; $99.99 ÷ 1.1 million gives $0.91 on Startup; $249.99 ÷ 3.3 million gives $0.76 on Pro. Google's numbers are from the pages linked above. We did not run Vertex AI Search, so it gets no column: its price and free allowance are in the section above, as Google lists them.
What a search returns
One POST, with the key in a header. The engine ID is gone; the sites it stood for go in the query:
curl -X POST https://scrapingbot.io/api/v1/google \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"endpoint": "/search", "params": {"q": "asyncio (site:docs.python.org OR site:realpython.com)", "gl": "us", "page": 1}}'
{
"success": true,
"searchParameters": { "q": "asyncio (site:docs.python.org OR site:realpython.com)", "engine": "google", "gl": "us", "page": 1, "type": "search" },
"organic": [
{
"displayedLink": "https://docs.python.org › 3 › library › asyncio.html",
"link": "https://docs.python.org/3/library/asyncio.html",
"position": 1,
"snippet": "asyncio is a library to write concurrent code using the async/await syntax. asyncio is used as a foundation for multiple Python asynchronous frameworks",
"title": "asyncio — Asynchronous I/O"
},
{
"displayedLink": "https://docs.python.org › 3 › howto › a-conceptual-overview-of-as...",
"link": "https://docs.python.org/3/howto/a-conceptual-overview-of-asyncio.html",
"position": 2,
"snippet": "asyncio automatically associates tasks with the event loop for you. This automatic association was purposely designed into asyncio for the sake of simplicity.",
"title": "A conceptual overview of asyncio"
},
…
],
"duration": "0.82",
"statusCode": 200,
"creditsUsed": 10
}
Ten results came back, all from the two sites. On a broad query the response also carries peopleAlsoAsk and relatedSearches when Google shows them, and some results have a date.
A drop-in for cse.list
Most code that used the JSON API does three things: builds a request, loops over items and follows queries.nextPage. Save this as cse.py and only the first of the three changes. It turns the JSON API's parameters into a Google query, calls ScrapingBot, and answers in the JSON API's shape.
It is strict on purpose. A parameter with no equivalent here, such as cx, safe=active, lr or sort, raises a ValueError before any search is made, so a restriction your code relied on is never dropped without a word. The tables below say which parameters those are.
import html
import time
from urllib.parse import urlsplit
import requests
API = "https://scrapingbot.io/api/v1/google"
HEADERS = {"x-api-key": "YOUR_API_KEY"}
SUPPORTED = {"gl", "hl", "dateRestrict", "searchType", "exactTerms", "excludeTerms", "orTerms", "hq",
"siteSearch", "siteSearchFilter", "fileType"} # the cse.list parameters this file can honour
class SearchError(Exception):
"""A search that failed: args are the HTTP status and the API's message."""
def build_query(q, sites=None, exactTerms=None, excludeTerms=None, orTerms=None, hq=None,
siteSearch=None, siteSearchFilter="i", fileType=None, **ignored):
"""Fold the JSON API's query parameters into Google operators, which work in q."""
parts = [q]
if hq:
parts.append(hq)
if exactTerms:
parts.append('"' + exactTerms.replace('"', "") + '"')
if orTerms:
parts.append("(" + " OR ".join(orTerms.split()) + ")")
if excludeTerms: # one word, or a phrase kept whole
phrase = excludeTerms.replace('"', "").strip()
parts.append('-"' + phrase + '"' if " " in phrase else "-" + phrase)
if fileType:
parts.append("filetype:" + fileType.lstrip("."))
if siteSearch:
parts.append(("-" if siteSearchFilter == "e" else "") + "site:" + siteSearch)
if sites: # what cx used to hold: the sites your engine searched
parts.append("(" + " OR ".join("site:" + s for s in sites) + ")")
return " ".join(parts)
def call(endpoint, params, tries=4):
"""One search: 10 credits on success. Failed calls are refunded."""
error = "no answer"
for attempt in range(tries):
try:
res = requests.post(API, headers=HEADERS, timeout=60, json={"endpoint": endpoint, "params": params})
body = res.json()
except (requests.RequestException, ValueError) as err: # dropped connection or not JSON
error = str(err)
time.sleep(2 ** attempt)
continue
if body.get("success"):
return body
error = body.get("error")
if res.status_code not in (408, 429) and res.status_code < 500:
raise SearchError(res.status_code, error) # 400, 401, 402: retrying will not help
time.sleep(2 ** attempt)
raise SearchError(503, f"kept failing: {error}")
def cse_list(q, sites=None, num=10, start=1, **cse):
"""One page of results in the shape cse.list returned. `sites` stands in for cx (None: the whole web)."""
if not 1 <= num <= 10:
raise ValueError("num must be 1 to 10")
if start < 1:
raise ValueError("start counts from 1")
refused = sorted(k for k, v in cse.items() if k not in SUPPORTED and v not in (None, "", "off"))
if refused: # better no search than a paid one that quietly drops a restriction
hint = ": pass sites=[...] in its place" if refused == ["cx"] else ""
raise ValueError("no equivalent here for " + ", ".join(refused) + hint)
image = cse.get("searchType") == "image"
params = {"q": build_query(q, sites, **cse)}
for key in ("gl", "hl"): # the market: country and interface language
if cse.get(key):
params[key] = cse[key]
if cse.get("dateRestrict"): # d7, w2, m6 and y1 mean the same to Google's own filter
params["tbs"] = "qdr:" + cse["dateRestrict"]
page, skip = divmod(start - 1, 10) # Google's pages hold up to ten results; `page` counts from 0 here
while True:
body = call("/images" if image else "/search", {**params, "page": page + 1})
found = body.get("images" if image else "organic") or []
rows = found[skip:skip + num]
if rows or not found:
break
page, skip = page + 1, 0 # start pointed past the end of a short page: carry on with the next one
first = page * 10 + skip + 1
request = {"searchTerms": q, "count": len(rows), "startIndex": first}
out = {"kind": "customsearch#search", "queries": {"request": [request]},
"searchInformation": {"searchTime": float(body.get("duration") or 0)}}
if rows: # like the JSON API, no "items" key at all when there is nothing left
following = first + num if skip + num < len(found) else (page + 1) * 10 + 1
out["items"] = [image_item(r) if image else web_item(r) for r in rows]
out["queries"]["nextPage"] = [{"searchTerms": q, "count": num, "startIndex": following}]
return out
def web_item(r):
link, title, snippet = r.get("link") or "", r.get("title") or "", r.get("snippet") or ""
return {"kind": "customsearch#result", "title": title, "htmlTitle": html.escape(title), "link": link,
"displayLink": urlsplit(link).netloc, "snippet": snippet, "htmlSnippet": html.escape(snippet),
"formattedUrl": link}
def image_item(r):
image = {"contextLink": r.get("link") or "", "width": r.get("imageWidth"), "height": r.get("imageHeight"),
"thumbnailLink": r.get("thumbnailUrl") or "", "thumbnailWidth": r.get("thumbnailWidth"),
"thumbnailHeight": r.get("thumbnailHeight")}
return {"kind": "customsearch#result", "title": r.get("title") or "", "link": r.get("imageUrl") or "",
"displayLink": r.get("domain") or "", "image": image}
def search_all(q, limit=100, **kwargs):
"""Follow nextPage until `limit` results or an empty page, dropping results a later page repeats."""
seen, items, start = set(), [], 1
while len(items) < limit:
page = cse_list(q, start=start, **kwargs)
fresh = [item for item in page.get("items", []) if item["link"] not in seen]
seen.update(item["link"] for item in fresh)
items += fresh
if not fresh or "nextPage" not in page["queries"]: # an empty page, or one with nothing new: the end
break
start = page["queries"]["nextPage"][0]["startIndex"]
return items[:limit]
Before and after, for a loop that prints results:
# Before: the Custom Search JSON API
import requests
res = requests.get("https://www.googleapis.com/customsearch/v1", timeout=30, params={
"key": GOOGLE_API_KEY, "cx": ENGINE_ID, "q": "asyncio", "num": 10, "start": 1, "gl": "us",
}).json()
for item in res.get("items", []):
print(item["displayLink"], "|", item["title"])
# After: the same loop on cse.py
from cse import cse_list
res = cse_list("asyncio", sites=["docs.python.org", "realpython.com"], num=10, start=1, gl="us")
for item in res.get("items", []):
print(item["displayLink"], "|", item["title"])
docs.python.org | asyncio — Asynchronous I/O
docs.python.org | A conceptual overview of asyncio
docs.python.org | Coroutines and tasks
realpython.com | What Is asyncio? (Video)
docs.python.org | Subprocesses
docs.python.org | asyncio.Queue
docs.python.org | Streams — Python 3.15.2 documentation
docs.python.org | Developing with asyncio
docs.python.org | High-level API Index
docs.python.org | Synchronization Primitives
The first item of that answer, as your code sees it:
{
"kind": "customsearch#result",
"title": "asyncio — Asynchronous I/O",
"htmlTitle": "asyncio — Asynchronous I/O",
"link": "https://docs.python.org/3/library/asyncio.html",
"displayLink": "docs.python.org",
"snippet": "asyncio is a library to write concurrent code using the async/await syntax. asyncio is used as a foundation for multiple Python asynchronous frameworks",
"htmlSnippet": "asyncio is a library to write concurrent code using the async/await syntax. asyncio is used as a foundation for multiple Python asynchronous frameworks",
"formattedUrl": "https://docs.python.org/3/library/asyncio.html"
}
search_all("site:docs.python.org asyncio", limit=60, gl="us") made seven calls, following nextPage six times, and returned 60 unique results in 14 seconds for 70 credits. The seventh call was needed because a few results repeat from page to page.
Leaving a JSON API setting in the call fails fast and costs nothing:
cse_list("asyncio", cx="017576662512468239146:omuauf_lfve", safe="active")
# ValueError: no equivalent here for cx, safe
Parameter by parameter
| cse.list | ScrapingBot | In cse.py |
|---|---|---|
key | x-api-key header | HEADERS |
cx | No engines. site: operators in q | sites=[…], or nothing for the whole web. A leftover cx is refused |
q, hq | q | Yes |
num (1 to 10) | num, up to 10 | Yes. A slice of a page costs the same 10 credits as the page, so 10 is the cheap choice |
start | page (1, 2, 3, …), ten results to a page | Yes, any start: 1, 11, 21 read whole pages, and a start inside a page begins there. nextPage never skips a result |
gl, hl | gl, hl | Yes |
dateRestrict (d7, w2, m6, y1) | tbs: qdr:d7, qdr:w2, qdr:m6, qdr:y1 | Yes |
siteSearch, siteSearchFilter | site:example.com or -site:example.com in q | Yes |
exactTerms, excludeTerms, orTerms | "a phrase", -word or -"a phrase", (a OR b) in q | Yes |
fileType | filetype:pdf in q | Yes |
searchType=image | The /images endpoint | Yes: link is the image, image.contextLink the page |
lr, cr | Choose the market with gl and hl | Refused. With a European gl, lr returned Google redirect links in place of page addresses in our test |
sort=date | None. Some results carry a date to sort on | Refused |
safe, filter, rights, linkSite, lowRange, highRange, the img… filters | Not tested by us | Refused, except safe=off, which is the default |
Response field by field
| JSON API | ScrapingBot | In cse.py |
|---|---|---|
items[].title, link, snippet | organic[].title, link, snippet | Same names |
items[].displayLink, formattedUrl | organic[].displayedLink is Google's breadcrumb, not a host name | The host of link, and link |
items[].htmlTitle, htmlSnippet | Plain text only | The plain text, HTML-escaped, with no <b> around matches |
items[].pagemap (thumbnails, meta tags) | None | Missing. Fetch the page with the website endpoint when you need its meta tags |
items[].image (image search) | images[].imageUrl, link, thumbnailUrl, sizes | link, image.contextLink, thumbnailLink, width, height |
queries.nextPage[0].startIndex | Ask for the next page | Present whenever the call returned results: the next unread result |
searchInformation.totalResults | None | Missing. Page until items is absent |
searchInformation.searchTime | duration | Yes |
spelling.correctedQuery | None. Google corrects a misspelled query silently | Missing |
promotions, context, items[].labels | None: they belong to an engine's settings | Missing |
| Not in the JSON API | peopleAlsoAsk, relatedSearches, organic[].date | Call the endpoint directly to read them |
What we measured
On December 1, 2026 we ran 30 queries twice each through /search: programming questions, shopping and everyday queries, site: searches, and one each in Spanish, German and French. Then we paged four queries to the end.
- All 60 searches succeeded. The median took 0.99 seconds, nine in ten finished within 2.6 seconds and the slowest took 3.8.
- A page is what Google shows, not always ten. First pages held 5 to 10 organic results, 8 at the median: Google gives part of the page to other blocks.
numcan cut a page down but not fill it up. - The same query gave the same list. All 30 pairs matched result for result, seconds apart. Over days, Google's results move as they do in a browser.
- Depth is about the JSON API's. Paged to the end, four queries gave 85, 91, 93 and 99 unique results over 10 to 13 pages; another pass over one of them reached 100. Later pages repeat a few earlier results, which is why
search_alldrops them. - The page after the last one is empty and charged. There is no total to tell you where the end is, so the final call of a full read costs 10 credits and returns no results. Stop at the depth you need.
positionrestarts on every page. The first result of page 3 is position 1. Add the results of the pages before it if you track rank.- Extras came with most answers. People also ask in 38 of the 60, related searches in 42, and a date on 190 of the 496 results.
- Operators did what they say. A query with 12
site:operators returned only those sites.-site:, quotes,OR,filetype:pdfand date ranges of 3 days, a week, 6 months and 2 years all filtered as asked.
What it costs
The JSON API's price was simple: 100 queries a day free, then $5 per 1,000, up to 10,000 a day. Spread evenly over a 30-day month, against the ScrapingBot plan that covers the same volume:
| Searches a month | Custom Search JSON API | ScrapingBot |
|---|---|---|
| 3,000 (100 a day) | $0 | $49.99 (Starter, up to 27,500) |
| 10,000 | $35 | $49.99 (Starter) |
| 25,000 | $110 | $49.99 (Starter) |
| 100,000 | $485 | $99.99 (Startup, up to 110,000) |
| 300,000 (the JSON API's daily cap) | $1,485 | $249.99 (Pro, up to 330,000) |
The crossover is near 13,000 searches a month. If you lived inside the 100 free queries a day, every replacement costs more than you paid, ours included: the free 100 credits are 10 searches, enough to test and no more. Vertex AI Search's 10,000 queries a month at no cost is the closest thing to the old free tier, for the sites you can index. ScrapingBot credits are shared with the Instagram, TikTok, Amazon and website endpoints, and failed calls are refunded.
If your engine searched your own site
Then do not replace it with a search API, ours or anyone's. Asking Google about your own pages for every visitor's query adds about a second (our median was 0.99), costs 10 credits a search, and only finds what Google has indexed, in the order Google prefers. An index you control is the right tool: Vertex AI Search is the one Google points to, and a self-hosted search engine does the job for a small site. A site: query through ScrapingBot is still handy for the opposite question: what Google shows for your pages, and where.
Where to go from here
- Feeding results to a model? Google results as JSON for an AI agent or RAG builds a compact, cited context block from the same endpoint.
- Coming from another search API? ScrapingBot vs SerpApi has the same kind of field mapping.
- Local results are their own endpoints: Google Maps places and reviews to CSV.
- The Google API reference lists every parameter of web, image, news, video, shopping and maps search, and the Google Search API page has live examples.
- Agents can call the same search through the hosted MCP server, with no code at all.
Common questions
Is the Google Custom Search JSON API shutting down?
Yes. Google's own overview page says the Custom Search JSON API is closed to new customers, that existing customers have until January 1, 2027 to transition to an alternative solution, and that its pricing applies "until the service discontinuation on January 1, 2027". We read that page on December 1, 2026. If your code calls googleapis.com/customsearch/v1, plan the move now.
What does Google recommend instead of the Custom Search JSON API?
Two things, on the same notice. For searching up to 50 domains, Vertex AI Search. For full web search, Google asks you to contact it about its full web search solution. There is no self-serve Google API for whole-web results after the JSON API.
What is a drop-in replacement for cse.list?
A function that takes the same arguments and returns the same shape: items with title, link, displayLink and snippet, plus queries.nextPage. The cse.py on this page does that on top of ScrapingBot's Google endpoint in about 120 lines of Python, so the code that reads results does not change. A parameter it cannot honour, such as cx or safe=active, raises an error before any search is made.
How do I replace the cx engine ID?
An engine ID stood for a list of sites. Put the sites in the query as site: operators instead: asyncio (site:docs.python.org OR site:realpython.com). A query with 12 site: operators worked in our test and every result came from a listed site. cse.py takes the list as sites=[...], and refuses a leftover cx so a site search never turns into a whole-web search by accident.
Is ScrapingBot cheaper than the Custom Search JSON API?
Above about 13,000 queries a month, yes. The JSON API gave 100 queries a day free and charged $5 per 1,000 after that. ScrapingBot charges 10 credits per search: $1.82 per 1,000 on Starter ($49.99 a month for 27,500 searches) and $0.91 on Startup. Below about 13,000 a month the JSON API was cheaper, and free under 100 a day.
Will I get the same results my Programmable Search Engine returned?
No. ScrapingBot returns the results google.com shows for the query in the country and language you pick. An engine you tuned with promotions, refinements or boosted sites ranked differently, and those settings do not carry over. Compare a sample of your real queries before you switch.