GET endpoint that accepts your query and returns structured web results. Every request must include your API key, a Search Engine ID (cx), and a query string. All other parameters are optional and let you filter, page, localize, and sort the results your users receive.
Endpoint
Request Parameters
Required Parameters
string
required
Your Google API key. Create one in the Google Cloud Console. Every request must include this parameter.
string
required
The Search Engine ID (also called Programmable Search Engine ID) that defines the scope and configuration of your search. Create and manage search engines at programmablesearchengine.google.com.
string
required
The search query. Supports the same query operators as google.com — for example
site:, filetype:, -term, and quoted phrases. Maximum length is 2,048 characters.Pagination Parameters
integer
default:"10"
Number of results to return in a single page. Accepted values are
1 through 10. To retrieve more results, use the start parameter to page through them.integer
default:"1"
The index of the first result to return. Use in combination with
num to paginate. The maximum value is 91; combined with num=10 this gives you access to up to 100 results per query.Language and Region Parameters
string
Restricts results to documents written in a specific language. Pass a Google language code such as
lang_en (English), lang_fr (French), or lang_de (German). See the full list of supported language codes.string
Boosts results relevant to a specific country. Accepts a two-letter country code (ISO 3166-1 alpha-2), such as
us, gb, or de. This biases results toward that country without hard-filtering them.string
Restricts results to documents originating from a particular country. Uses Google country codes such as
countryUS or countryGB. Unlike gl, this parameter hard-filters by the country of origin of the result page.Safety Parameters
string
default:"off"
SafeSearch setting for the query. Accepted values:
active— filters explicit adult content from results.off— disables SafeSearch filtering.
Date and Freshness Parameters
string
Restricts results to pages indexed within a specified time period. Format:
[d|w|m|y][number] where the prefix is the unit:d5— last 5 daysw2— last 2 weeksm3— last 3 monthsy1— last year
string
Controls the sort order of results. Pass
date to sort by recency. You can also specify a structured data field such as sort=date:r:20230101:20231231 to restrict by date range.Content Filtering Parameters
string
Limits results to a specific site or domain, for example
siteSearch=docs.example.com. Use with siteSearchFilter to include or exclude the site.string
Controls whether
siteSearch includes or excludes the specified site. Accepted values:i— include only results from the specified site.e— exclude results from the specified site.
string
Requires every result to contain this exact phrase. Equivalent to wrapping the phrase in quotes in the query string. Only one phrase is allowed per request.
string
Ensures that results do not contain this word or phrase. Equivalent to prefixing a term with
- in the query string.string
Adds additional search terms that are joined with OR. Results must contain at least one of the terms in
q OR at least one term in orTerms.string
Restricts results to files with a specific extension. Common values:
pdf, doc, xls, ppt, txt. You can combine multiple types with a pipe: pdf|doc.string
Filters results by Creative Commons license type. Accepted values include
cc_publicdomain, cc_attribute, cc_sharealike, cc_noncommercial, cc_nonderived, and combinations thereof separated by |. For example: cc_publicdomain|cc_attribute.string
default:"1"
Toggles duplicate content filtering. Pass
0 to disable the filter and receive more raw results. Pass 1 (default) to enable it.Example Request
The following request searches for “climate change policy” in English, filtered to the last 3 months, returning the first 5 results.cURL
Example Response
Response Fields
string
The type identifier for this response object. Always
"customsearch#search".object
Describes the URL template used to construct the request. Useful for constructing follow-up queries programmatically.
object
Metadata about the current page of results and adjacent pages.
object
Statistics about the search execution.
array
The list of search result objects for this page. May contain up to
num entries (default 10).Error Codes
The free tier allows 100 queries per day per project. Paid usage supports up to 10,000 queries per day. Monitor your quota in the Google Cloud Console.