Google site search API (now custom search API since Google site search is shutting down) lets you develop applications to get and show results from Google custom/ site search programmatically. Google site search In this article we will discuss the components of the google site search API and where to find them. Google search for sites has many restrictions and you could sign up for expertrec site search engine using the link below.
The usual API call is
Here parameters could be –
- q– query string
- cx– Custom search engine ID.
- fileType– bmp, gif, jpg, png, pdf etc
- num-number of search results to display
- searchType- search type.
- sort-Sort by functionality to use.
For a list of all query parameters, go to this link.
A sample api call would be like this-
Response of this API will be in JSON format for you to consume to build your search application.
Getting your API Key
- Go to https://developers.google.com/custom-search/json-api/v1/overview
- Click on get key.
- Click create new project.
- This will generate your new API key.
- You can restrict the usage of this API key in your google api console https://console.developers.google.com/apis
Getting your CX / Search engine ID:
Go to your custom search / site search control panel-> edit search engine->Basics->Details->Search engine ID.
This is your search engine ID.
If you are finding issues with the Google site search API, you could try out expertrec’s site search API, which is easier to implement.
Expertrec’s Google site search replacement API-
Go to https://cse.expertrec.com?platform=cse and enter your website and sitemap URLs to get your crawl done. Go and click on your demo link.
- In your demo link open developer tools (control+shift+I) on your chrome browser.
- Go to network tab.
- Go to XHR section.
- Search for expertrec.
- Click on searchv7…
The API will be of this format-
Expertrec site search API parameters-
- org_id- Your unique ID that identifies your website/ websites.
- q- Keyword.
- page- pagination
- size- number of search results to be displayed.
The results will be in JSON format and will be similar to this screen shot-