Skip to main content
The Custom Search JSON API lets you embed Google-quality web search directly in your application. Every request is a plain HTTPS 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 by cx). 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 110. 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.
Restrict or exclude results from a specific domain. Pair with siteSearchFilter to control whether the domain is included or excluded.Example: siteSearch=developer.mozilla.org
string
Controls how siteSearch is applied. Accepts:
  • i — include only results from the specified site
  • e — exclude all results from the specified site
Defaults to 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). Use start to move through pages:
Setting start above 91 returns a 400 Bad Request error. To retrieve beyond 100 results, rephrase the query or apply tighter filters.

Make your first web search request

1

Obtain your credentials

You need two values before making any request:
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” from bbc.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

Call the API in a loop, incrementing start by num each time, until items is absent from the response or start would exceed 91:
Use siteSearch with siteSearchFilter=i to replicate the site: operator at the API level:
Set siteSearchFilter=e to strip results from an unwanted domain:

Error reference

On 429 responses, wait at least one second before retrying. Implement exponential back-off with jitter for production workloads to stay within the 100 queries/day free tier or your paid project quota.