Google custom search JSON API is a RESTFUL API lets you develop applications to get and show search results (websearch, images) from Google custom search programatically.With this API, you can use RESTful requests to get either web search or image search results in JSON format.

The existing documentation on creating a google custom search using the api method is confusing and we will try to simplify the process here.

In this article we will see how we can create a custom search engine using the Google custom search api . We will also see what are the limitations of google custom search api and how we can over come them.

Get your site search API

Create a custom search engine at https://www.google.com/cse

The usual API call is

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 custom search JSON API simplified

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 google custom search API Key

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

Google custom search JSON API simplified

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 custom search JSON API simplified

Testing your google custom search JSON API-

You can test you google custom search api using the google api explorer 

google custom search JSON simplifiedYou could try out expertrec’s site search API, which is easier to implement with no coding needed at all. Expertrec’s site search api is also available if in case you want to go through the api route.

Limitations of google custom search api-

  1. You can only retrieve a maximum of 10 search results at a time .
  2. Query limit of 100 per day.

Expertrec’s Google custom search replacement API to overcome 

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.

Get your expertrec site search API

Go to https://cse.expertrec.com/csedashboard/home/Status to get your API key

 

The API will be of this format-

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-

 

Get your site search API


muthali ganesh

Muthali loves writing about emerging technologies and easy solutions for complex tech issues. You can reach out to him through chat or by raising a support ticket on the left hand side of the page.