Programmatic search turns raw web and enterprise data into structured results your software can rank, filter, and act on. When people say “Google Search API,” they usually mean the Custom Search JSON API—a REST interface that returns web and image results from a Programmable Search Engine in JSON format.
Crucially, Google is discontinuing the Custom Search JSON API on January 1, 2027, and it is already closed to new customers. Existing integrations still run through the end of 2026, while modern search and retrieval workloads increasingly rely on newer platforms such as Agent Search (part of Google Cloud’s Generative AI App Builder / Vertex AI search stack) for blended website, structured, and unstructured data search with grounded AI answers.
How the Custom Search JSON API Works
Under the hood, the Custom Search JSON API follows the OpenSearch 1.1 specification and pairs two identifiers on every request: an API key (for project authentication, quotas, and billing) and a Search Engine ID (often called cx, which points to your Programmable Search Engine configuration).
- Structured JSON payloads: Responses return clean fields—titles, URLs, snippets, and metadata—so your code does not have to scrape or parse raw HTML.
- Scoped search via Programmable Search Engine: You can restrict searches to specific domains, search across a broader web configuration, and tune how sites are prioritized.
- Query and filter controls: Parameters let you target web or image results, narrow by language, country/geolocation, file type, or date, and apply domain filters.
- Pagination limits: Requests use
num(up to 10 results per page) andstart(the starting index), capped at the first 100 results for a given query. - Quota and pricing model: Existing customers get 100 free queries per day, with paid usage billed at $5 per 1,000 additional queries up to 10,000 queries per day.
Setup and a Quick Python Example
For teams with active access before retirement, wiring up a request takes three setup steps:
- Create a project in the Google Cloud Console and enable the Custom Search JSON API.
- Create a Programmable Search Engine and copy its Search Engine ID (
cx). - Generate an API key in Google Cloud and restrict it properly before shipping code.
import os
import requests
API_KEY = os.environ["GOOGLE_API_KEY"]
CX = os.environ["GOOGLE_SEARCH_CX"]
def search_web(query: str, num_results: int = 5) -> list[dict]:
url = "https://www.googleapis.com/customsearch/v1"
params = {
"key": API_KEY,
"cx": CX,
"q": query,
"num": min(max(num_results, 1), 10),
}
response = requests.get(url, params=params, timeout=10)
response.raise_for_status()
data = response.json()
return [
{
"title": item.get("title"),
"link": item.get("link"),
"snippet": item.get("snippet"),
}
for item in data.get("items", [])
]
if __name__ == "__main__":
for row in search_web("OpenSearch 1.1 JSON API"):
print(f"- {row['title']}: {row['link']}")
Strengths, Trade-Offs, and What Comes Next
| Dimension | Custom Search JSON API | Modern Enterprise / Retrieval Alternatives (
Comments |
|---|
Leave a Reply