google site search api

[SOLVED] Google site search API simplified 2020

Rate this article

Share this article

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.

 

Create your custom search engine

 

Google site search API Call

The usual API call is

https://www.googleapis.com/customsearch/v1?parameters

Google search API query parameters

Here parameters could be –

  1. q– query string
  2. cx– Custom search engine ID.
  3. fileType– bmp, gif, jpg, png, pdf etc
  4. num-number of search results to display
  5. searchType- search type.
  6. sort-Sort by functionality to use.

For a list of all query parameters, go to this link.

google site search API

GOOGLE SEARCH API SAMPLE API CALL

A sample API call would be like this-

https://www.googleapis.com/customsearch/v1?key={YOUR_API_KEY}&cx={CUSTOM_SEARCH_ENGINE_ID}&q={KEYWORD}
https://www.googleapis.com/customsearch/v1?key=AIzaSyCVAXiUzRYsML1Pvcx=012278024424817052234:cimrvj4h4uk&q=jeff

The response of this API will be in JSON format for you to consume to build your search application.

google site search api

Getting your API Key

  1. Go to https://developers.google.com/custom-search/json-api/v1/overview
  2. Click on the get key.google site search api
  3. Click to create a new project.google site search api
  4. This will generate your new API key.google site search api
  5. You can restrict the usage of this API key in your google API console https://console.developers.google.com/apis

google site search api

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.

google site search api

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.

Create your custom search engine

  1. In your demo link open developer tools (control+shift+I) on your chrome browser.
  2. Go to the network tab.
  3. Go to the XHR section.
  4. Search for expertrec.
  5. Click on searchv7…

google site search api

The API will be of this format-

https://searchv7.expertrec.com/v6/search/{org_id}/?q={keyword}&page={pagination}&size={number_of_search_results}
https://searchv7.expertrec.com/v6/search/79b96660-27e0-11e8-a8e3-12b6486824f4/?q=a&page=0&size=16

Expertrec site search API parameters-

  1. org_id- Your unique ID that identifies your website/ websites.
  2. q- Keyword.
  3. page- pagination
  4. size- number of search results to be displayed.

The results will be in JSON format and will be similar to this screenshot-

 

Create your custom search engine

Are you showing the right products, to the right shoppers, at the right time? Contact us to know more.
You may also like