Search API Connector Documentation
Import Google SERP Data to Google Sheets
In this guide, we’ll walk through how to use Google's Programmable Search Engine API (previously known as the Custom Search API) to import search engine result page (SERP) data to Google Sheets, using the API Connector add-on for Sheets.
This free API is primarily designed for creating applications that retrieve and display search results programmatically, like a search box widget that you place on your own website. However, it also lets you query Google's search engine check the search result rankings for any keyword, using Google's own search engine results page data.
- Before You Begin
- Part 1: Create a Programmable Search Engine
- Part 2: Get your Programmable Search API Key
- Part 3: Pull Google SERP Data into Sheets
- Part 4: Handle Pagination
- Part 5: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Create a Programmable Search Engine
- While logged into your Google account, navigate to https://programmablesearchengine.google.com/controlpanel/all, and click Add.
- You'll be prompted to configure your custom search engine. Give your Search Engine a name, and choose to search the entire web (unless you specifically want to limit your results to a subset of pages). Click Create.
- Your search engine has been created. Click Customize.
- Scroll down the page and optionally adjust any settings. Note the search engine ID as we'll need that soon.
- That's it, your Google Programmable Search engine is ready.
Part 2: Get your Custom Search API Key
Accessing Google's Custom Search JSON API requires the use of an API key.
- Navigate to the Custom Search JSON API page and click Get a Key.
- Choose an existing project, or create a new one, and click Next.
- Note and copy your API key, you'll need this along with your custom search engine ID.
Part 3: Pull Google SERP Data into Sheets
For our first API request, we'll pull in the top 10 page titles, URLs, and snippets for a keyword.
- Open up Google Sheets and click Extensions > API Connector > Open > Create request.
- In the request form enter the following. Substitute in your own key, search engine ID, and keyword in the
- Request URL:
- Create a new tab and click Set current to use that tab as your data destination.
- Under Output options, set the Report style to 'compact'.
- Name your request and click Run. A moment later you’ll see a list of 10 search results populate your sheet.
- Fetch more records, or further customize your request by including any of the parameters available in the documentation. You can filter the response data by site, region, language, and so on.
Part 4: Handle Pagination
By default, the Custom Search API will return only 10 results. To get more, use the
num parameters as described in their documentation.
You can run through these request URLs manually, or use API Connector's pagination handling function to loop through these pages automatically, like this:
- Pagination type:
- Offset parameter:
- Limit parameter:
- Limit value:
- Run until:
choose when the request should stop running
This API will not return more than 100 total records, regardless of the actual number of search results.
Part 5: API Documentation
Official API documentation: https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list