Custom Google Search API

Photo by Benjamin Dada on Unsplash

If you want to get results of Google search results programmatically with the API, follow this tutorial.

Create Search Engine

Go to https://cse.google.com/cse/create/new

and create an engine. If you want a general search engine, leave the part where it asks you for a link empty. After it’s created, take the cx number. We’ll need it later.

Create Key/Get Custom Search API Key

This portion can be done in Google Cloud Console. If you don’t have a GCloud Project, you can create one here.

There are 2 ways of doing it: the fast way which just works, and the slower way which is “doing it properly”.

Fast Way

Go to https://developers.google.com/custom-search/v1/overview

Scroll down to API Key

Click Get a Key

Remember your API Key, we’ll use it later.

Slow Way

You can enable Custom Search API Key here.

Then go to Credentials

Click on CREATE CREDENTIALS, then API key.

Remember your API key, we’ll use it later.

Querying API

With the cx number and API key, we have everything we need to query Google API.

The query is of the form

https://www.googleapis.com/customsearch/v1?key=[API KEY]&cx=[CX NUMBER]&q=[QUERY]

For all query parameters, please see https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list

--

--

--

Senior Machine Learning Engineer — Snaptravel

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Normalize an Address in C/C++

ipl boot from vfio-ccw dasd

Marvel vs DC Data Analysis in Python

Docker and its Uses

Disruptive Innovation: Fabricating the Unimaginable

Dungeon Escape — Moss Giant Animation Setup

Clash of Kings Optimization Details — Phase 5

Dive into Design Patterns

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Joey S

Joey S

Senior Machine Learning Engineer — Snaptravel

More from Medium

More than Autocompleter: Alibaba Cloud AI Coding Assistant

How to Unplug and Plug PDB(Pluggable DB) multiple Options- Copy,Nocopy & Move

Setting headers in postman via scripts

Raml 1.0 in Mulesoft — Basics