GET call that returns a JSON payload containing ranked results, pagination cursors, and rich metadata — no browser, scraping, or headless automation required.
How web search works
When you call the API, Google runs your query against the index defined by your Programmable Search Engine (identified bycx). By default the engine searches the entire open web; you can restrict or boost specific domains through the Search Engine control panel or via per-request parameters. Results come back in the items[] array, ordered by relevance, with up to 10 results per page.
Key parameters
string
required
The search query. Supports all standard Google search operators (
site:, intitle:, filetype:, -term, "exact phrase", OR, etc.).string
required
Your Programmable Search Engine ID. Find it in the Control Panel under Search engine ID.
string
required
Your Google API key. Create one in the Google Cloud Console.
integer
Number of results to return per page. Accepts
1–10. Defaults to 10. To retrieve more results, use start to paginate.integer
Index of the first result to return (1-based). Maximum value is
91, which means you can page through at most 100 results (ten pages of 10). Defaults to 1.string
Restrict or exclude results from a specific domain. Pair with
siteSearchFilter to control whether the domain is included or excluded.Example: siteSearch=developer.mozilla.orgstring
Controls how
siteSearch is applied. Accepts:i— include only results from the specified sitee— exclude all results from the specified site
i when siteSearch is set.string
Limit results to pages indexed within a recent time window. Format:
d[N] (days), w[N] (weeks), m[N] (months), y[N] (years).Examples: d7 (last 7 days), m3 (last 3 months), y1 (last year)string
Override relevance ranking. Set to
date to sort by the most recently indexed results first. Combine with dateRestrict to surface fresh content reliably.Pagination
The API exposes up to 100 results per query (10 pages × 10 results). Usestart to move through pages:
Make your first web search request
1
Obtain your credentials
You need two values before making any request:
- API key — create one at console.cloud.google.com/apis/credentials and enable the Custom Search API.
- Search Engine ID (
cx) — create a Programmable Search Engine at programmablesearchengine.google.com and copy the Search engine ID.
2
Send the request
Replace
YOUR_API_KEY and YOUR_CX with your real values, then run:3
Inspect the response
A successful response returns HTTP
200 with a JSON body. The items[] array contains your results; queries.nextPage[0].startIndex tells you the start value for the next page.Full curl example
The example below fetches the five most recent results about “climate policy” frombbc.com, published within the last month:
Sample JSON response
The following is a trimmed but structurally complete response showing two result items:Understand the response fields
string
Always
"customsearch#search" for search responses.object
Metadata about the search execution, including
searchTime (seconds) and totalResults (estimated count as a string).object
Contains
request[] (echoes your query parameters) and optionally nextPage[] and previousPage[] objects. Use nextPage[0].startIndex as your next start value.array
The ranked list of results. Each item contains
title, link, snippet, displayLink, formattedUrl, cacheId, and pagemap. See Result Item Structure for the full schema.Common patterns
Paginate through all results
Paginate through all results
Call the API in a loop, incrementing
start by num each time, until items is absent from the response or start would exceed 91:Restrict search to a single domain
Restrict search to a single domain
Use
siteSearch with siteSearchFilter=i to replicate the site: operator at the API level:Exclude a domain from results
Exclude a domain from results
Set
siteSearchFilter=e to strip results from an unwanted domain: