What is the Custom Search JSON API?
What is the Custom Search JSON API?
GET requests to https://www.googleapis.com/customsearch/v1. You provide a search query (q), your API key (key), and a Search Engine ID (cx), and Google returns up to 10 ranked results per request as structured JSON.Use it to power site search, research tools, content aggregators, or any feature where users need to find information across the web or within a specific set of sites.How do I get an API key?
How do I get an API key?
Open the Cloud Console
Create or select a project
Enable the API
Create credentials
Restrict the key (recommended)
key query parameter on every request:What is a Search Engine ID (cx)?
What is a Search Engine ID (cx)?
- Click Add to create a new engine.
- Choose whether to search the entire web or limit results to specific sites.
- Copy the Search engine ID from the Overview or Setup panel — it looks like
017576662512468239146:omuauf_lfve.
cx value travels as a query parameter:Can I search the entire web?
Can I search the entire web?
siteSearch parameter at request time:siteSearchFilter=i includes only pages from nature.com; setting it to e excludes them.How many results can I retrieve per request?
How many results can I retrieve per request?
num parameter (integer from 1 to 10):start parameter. start accepts values from 1 to 91, meaning you can access up to 100 results total across multiple requests (pages 1–10):What is the free tier limit?
What is the free tier limit?
How do I search for images?
How do I search for images?
searchType=image to your request. This tells the API to return image results instead of web page results:image object on each item with the following fields:imgSize—icon,small,medium,large,xlarge,xxlarge,hugeimgType—clipart,face,lineart,stock,photo,animatedimgColorType—color,gray,mono,transfileType— e.g.,jpg,png,gif
Can I restrict results to one site?
Can I restrict results to one site?
siteSearch at request time (flexible)Pass the domain you want to restrict to via the siteSearch parameter and set siteSearchFilter=i (include):q you send.Use Option 1 when the target domain varies per query. Use Option 2 when you always want results from the same fixed set of sites.siteSearch parameter by repeating the parameter or using comma-separated values, depending on your engine configuration.What does a 403 Forbidden error mean?
What does a 403 Forbidden error mean?
403 response means the API refused your request. The three most common causes are:error.errors[0].reason field in the JSON response body — it identifies the exact cause:How do I increase my quota?
How do I increase my quota?
Enable billing
Verify the new limit
Request a higher limit (if needed)
Can I search for videos or news?
Can I search for videos or news?
searchType values for video or news (only image is supported as a searchType). However, you can approximate these:- News — Add
dateRestrict=d7to surface recently published content, combine withsiteSearchtargeting news domains (e.g.,reuters.com,bbc.com), or usesort=dateto rank by recency. - Video — Use
siteSearch=youtube.com&siteSearchFilter=ito restrict results to YouTube, or addfiletype:mp4inside theqparameter.
What fields are returned in a search response?
What fields are returned in a search response?
items[] includes: