Skip to main content
TutorialsNovember 23, 2026 · 11 min read

Google Custom Search API shutdown: how to migrate

Google's Custom Search JSON API ends January 1, 2027. Replace your search results workflow with Spidra, including filters, pagination, and page content.

Google Custom Search API shutdown: how to migrate

Google's Custom Search JSON API is shutting down on January 1, 2027. If your application still calls customsearch.googleapis.com to retrieve search results, you need to replace that integration before the deadline.

The challenge isn't sending a search query somewhere else. It's keeping the parts of your application that depend on the results working: the fields you store, the sites you include or exclude, pagination, image results, and sometimes the content of each page. This guide shows how to move those workflows to Spidra Search, including what needs to change and what doesn't have a direct equivalent.

What's changing with Google Custom Search?

Google confirmed the transition on January 20, 2026. The Custom Search JSON API is already closed to new customers. Existing customers have until January 1, 2027, to migrate, according to the API overview.

The API let applications query a configured Programmable Search Engine using a q search term, a cx engine ID, and an API key. It returned structured web or image results that developers could store, filter, and use elsewhere in a product.

Its contract included ten results per request, offset pagination up to 100 results for one query, site restrictions, date and language controls, and an items array containing fields such as title, link, and snippet. Some applications also depended on pagemap, Google's structured metadata from a result page.

The Search Element, which embeds search into a website, is a different product. Google's transition also affects existing Search Elements configured to search the whole web, but a Search Element restricted to 50 or fewer sites has a continuing path. Don't confuse a search box on your site with a JSON API your backend calls.

Choose a replacement for the job, not just the API name

Google points customers searching up to 50 domains toward Vertex AI Search, now called Agent Search. That's useful when you want search over a known set of websites or your own content. It isn't a direct replacement for an app that needs open-web links, snippets, and rankings as JSON.

For that second use case, you need a search-results API. Options include providers focused on Google search results, as well as APIs that return web results from other sources. The distinction matters: if you're building an SEO rank tracker that requires Google's exact result order, choose a provider that explicitly offers Google SERPs. If you need relevant links and page content to power research, enrichment, monitoring, or AI agents, you can evaluate Spidra Search.

Spidra returns search results as data instead of generating an answer. A search can return web, news, image, video, research, or developer results, with fields for each source. You can also fetch the content behind selected results using the same API.

Replace your Custom Search call with Spidra

Let's keep the search itself the same so the difference is easy to see. Here's what a Python request to Google's JSON API looks like for an existing customer:

# Old Google Custom Search request
import os
import requests

response = requests.get(
    "https://customsearch.googleapis.com/customsearch/v1",
    params={
        "key": os.environ["GOOGLE_API_KEY"],
        "cx": os.environ["GOOGLE_CSE_ID"],
        "q": "best espresso machine",
        "num": 3,
    },
    timeout=30,
)
response.raise_for_status()
results = response.json().get("items", [])

The rest of your code would typically read item["title"], item["link"], and item.get("snippet").

With Spidra, create an account, generate an API key, and install the Python SDK:

pip install spidra

Set the key in SPIDRA_API_KEY, then run this search:

# search_example.py
import os
from spidra import Spidra

client = Spidra(api_key=os.environ["SPIDRA_API_KEY"])
search = client.search("best espresso machine", sources=["web"], limit=3)

for item in search.data.web or []:
    print(item.position, item.title, item.url)

Here's the kind of output returned by this exact query, using results from a Spidra Search example:

1 The 16 Best Espresso Machines of 2026, Tested & Reviewed https://www.seriouseats.com/best-espresso-machines-5185482
2 Best Espresso Machines 2026 | Tested - Forbes Vetted https://www.forbes.com/sites/forbes-personal-shopper/article/best-espresso-machine/
3 The 7 best espresso machines you can buy in 2026 - Tom's Guide https://www.tomsguide.com/home/coffee-makers/best-espresso-machines

The returned records are structured. One result, shortened to its core fields, looks like this:

{
  "title": "The 16 Best Espresso Machines of 2026, Tested & Reviewed",
  "url": "https://www.seriouseats.com/best-espresso-machines-5185482",
  "description": "We tested 41 home espresso machines to find which 16 pulled the best shots, steamed latte art-worthy microfoam, and were easy to use.",
  "position": 1
}

The important difference is the object shape. Google called the URL field link and the summary snippet; Spidra uses url and description. Spidra also includes position. Descriptions can be missing, so don't make that field mandatory in your application.

The Python SDK handles the search job and polling for you. If you use the REST API directly, submit POST https://api.spidra.io/api/search with an Authorization: Bearer header. A request with wait: true can return the result immediately; if it doesn't finish within the wait window, poll GET /search/{jobId}. The Search API reference covers both paths.

Keep the same fields in the rest of your application

If a larger application expects Google's items structure, normalize the Spidra result once at the API boundary:

def as_cse_items(search):
    return [
        {
            "title": hit.title,
            "link": hit.url,
            "snippet": hit.description or "",
            "position": hit.position,
        }
        for hit in (search.data.web or [])
    ]

items = as_cse_items(search)

This keeps the fields your existing interface or database needs without pretending that the entire Google response can be reproduced. In particular, Google's pagemap, searchInformation.totalResults, and spelling suggestions do not appear in a normal Spidra Search response.

Map the filters your code already uses

A migration usually breaks at the options developers forgot were important. Here's how the common Custom Search parameters translate:

Google Custom Search

Spidra Search

What to check

q

query

The query string carries over

num (1-10)

limit (1-20 per source)

The limit is a maximum, not a guaranteed count

siteSearch and siteSearchFilter

includeDomains or excludeDomains

Applied per request, not through a saved cx engine

searchType=image

sources: ["images"]

Image records include image URLs and thumbnails

gl

country

Influences geographic relevance rather than strictly filtering

lr / hl

language

A preference; validate multilingual queries

dateRestrict

timeRange or startDate / endDate

Fixed time buckets or an explicit date interval

fileType

filetype

Supports common document types, including PDF and DOCX

safe

safeSearch

off or strict; no moderate setting

start / queries.nextPage

pageTokens / nextPageTokens

Cursor pagination replaces offsets

pagemap

Optional page fetch via scrapeOptions

Not an equivalent metadata object

totalResults

No equivalent

Use the presence of a next-page token

For example, a CSE configured to search a curated set of documentation sites can become a per-request domain filter:

results = client.search(
    "python tutorial",
    sources=["web"],
    include_domains=["docs.python.org"],
    limit=10,
)

Spidra checks domain inclusion and exclusion on the returned web results. That is different from a recency preference like time_range="week", which can influence the search without guaranteeing that every result falls inside the last seven days. For an explicit window, use startDate and endDate with the REST API, or the equivalent options your SDK supports.

If your current engine combines search across your own domain with curated third-party sites, preserve that domain list in application configuration. Spidra doesn't automatically inherit the Google engine identified by cx.

Replace offset pagination with next-page tokens

Google let you ask for a result starting at start=11, then start=21, until you reached its 100-result ceiling. Spidra uses a cursor returned with the results. That cursor is the signal to ask for another page.

Here's how to gather up to three pages without storing duplicate URLs:

query = "best espresso machine"
seen = set()
records = []
page_tokens = None

for _ in range(3):
    options = {"sources": ["web"], "limit": 10}
    if page_tokens:
        options["page_tokens"] = page_tokens
    page = client.search(query, **options)
    for hit in page.data.web or []:
        if hit.url not in seen:
            seen.add(hit.url)
            records.append({"title": hit.title, "url": hit.url})
    token = (page.data.next_page_tokens or {}).get("web")
    if not token:
        break
    page_tokens = {"web": token}

records now contains unique result URLs collected from the pages that were returned. The loop stops early when there's no next-page token, and the three-page limit prevents an unexpectedly deep search from running indefinitely.

Deep pagination is not a promise of an unchanging result set. Search sources can shift between requests, and the original November evaluation found some repeated URLs across long pagination chains. Deduplicating by URL is a sensible precaution even when the API filters adjacent-page duplicates.

Get the page behind a search result

For an AI agent or research product, a title and snippet may not be enough. You might need the article text so your application can extract information, create summaries, or attach evidence to a result.

Spidra can fetch selected result pages in the same search request:

from spidra.types.search import SearchScrapeOptions

with_content = client.search(
    "how to redact data in posthog",
    sources=["web"],
    limit=2,
    scrape_options=SearchScrapeOptions(formats=["markdown"], max_results=1),
)

For the first result, the API can add a markdown field alongside the URL, title, description, and position. For example, the documented result begins with the title of PostHog's data redaction tutorial, followed by the page content as Markdown.

Only the first max_results results are fetched for content. A page that cannot be read is left without markdown; the search results themselves still come back. If you need a custom JSON schema, browser interactions, or more control over a particular URL, send that URL to Spidra Scrape instead. Search finds relevant pages; Scrape extracts what you need from them.

That's the larger benefit of migrating to Spidra if your product uses web data for more than displaying links. The same account also supports Batch Scrape, Crawl, and other tools, so your workflow can continue from discovering a URL to processing its content without another search integration.

Go beyond the web-only result list

Once your application can work with Spidra's result objects, you can ask for different sources without building a separate search integration for each one. That can matter when a research tool needs both the news about a topic and the primary technical discussions around it.

For example, this query asks for news, academic papers, and developer discussions together:

research = client.search(
    "vector database",
    sources=["news", "research", "developer"],
    limit=3,
)

The response separates the sources into research.data.news, research.data.research, and research.data.developer. Each source has its own useful fields: news dates, research authors and DOIs when available, and developer results from GitHub issues or pull requests. You can also ask the developer source for repositories instead of issues using developerTypes in the REST API.

This is where Spidra becomes more than a substitute for a discontinued endpoint. Your search-backed feature can grow into an evidence-gathering or enrichment workflow without creating a different provider integration for every new source. The results are still just data; you decide how your application verifies, ranks, stores, or summarizes them.

Budget for the new request model

Google's outgoing API offers existing customers 100 free searches a day, then charges $5 per 1,000 searches, with a daily limit of 10,000. Those terms end with the API.

Spidra bills for results returned: one credit per ten results, per source, rounded up. A ten-result web search costs one credit, while ten results each from web, news, and images cost three credits. Fetching the content of a result page costs one additional credit per page fetched. A search source that returns nothing costs no credits.

Spidra's Free plan includes 300 one-time credits without a card. Paid plans have monthly credit allowances, and the current options are listed on the pricing page. Because a search with multiple sources or page content costs more than a simple web search, compare the cost of your actual query mix rather than using a flat cost per API request.

Completed search responses include creditsUsed, so you can log the charge alongside the query and number of results. That makes it easier to detect cost changes when you add another source or start fetching article content.

What should you test before switching production traffic?

There is no exact one-for-one migration from a configured Google engine. Work through these checks using traffic from your own application:

  1. Identify your search contract. Find every use of cx, siteSearch, dateRestrict, searchType, pagemap, and totalResults, including fields used by background jobs rather than the interface.
  2. Compare real queries. Run a representative set through your existing engine and Spidra before the Google endpoint closes. Check whether the returned URLs and source mix are useful for the task, not whether rankings happen to match.
  3. Update the response boundary. Normalize link to url, snippet to description, and treat source-specific metadata as optional. Don't map a missing field to a fabricated value.
  4. Change pagination and filtering. Replace numeric offsets with next-page tokens, keep domain restrictions in request options, and deduplicate URLs when collecting multiple pages.
  5. Roll out behind a switch. Measure empty results, field completeness, response times, cost per completed query, and any downstream failures. Keep your old integration available for comparison until you've finished validation, then remove it before January 1, 2027.

One final distinction: Spidra's web results do not guarantee the same index, ranking, or engine-specific features as Google CSE. If exact Google SERPs, the old engine's promoted results, or Google's pagemap are critical to your product, evaluate that requirement explicitly rather than treating search APIs as interchangeable.

Make the move while your current integration still works

The safest migration is one you can compare against the old system. Start with one production query, verify the result fields and filtering, then move the rest of the workload once your application handles the new response and pagination correctly.

Create a free Spidra account and run the Python example above with a query your product already uses. If you need the full request and response contract, use the Search API documentation.

Frequently asked questions

Google says existing customers must migrate by January 1, 2027. The Custom Search JSON API is already closed to new customers, so new integrations need a different API now.

Share this article

You build the product.
Spidra handles the data work.

Start with 300 free credits, about 300 pages. No credit card required.