Get SEO Data with the Google Custom Search JSON API

API Connector Add-On for Google Sheets

Check out my API Connector Add-on to easily connect and pull data from thousands of platforms (e.g. Shopify, Harvest, Mailchimp, ActiveCampaign, Google Ads, YouTube, etc.) directly into Google Sheets.

The Google Custom Search JSON 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, as part of this service, Google provides a free Google Search API that that lets you query Google’s search engine to check search engine result page (SERP) data. While constructing your queries, you can set different parameters like search country, language, exact terms, etc.

This post will describe the steps you can take to use the Google Custom Search JSON API to programmatically access search data from Google, for use in SEO analysis.


  1. Caveats
  2. Create your Custom Search Engine
  3. Modify your Search Engine to Search the Whole Web
  4. Get your Google Custom Search API Key
  5. Create a Search URL
  6. Run your Google Search API Request


Before we start, please be aware of the following:

  • the results may not exactly match the results you would get by running search queries on Google directly. Google explains this here, saying that the Google Custom Search API won’t include personalized results, and may include a subset of the total data. You can compare the two sets of results to determine whether this is a big factor or not for your queries (in my own tests, it wasn’t).
  • The Google Custom Search JSON API provides 100 search queries per day for free. If you need more, you’ll need to sign up for a billing account. Additional requests cost $5 per 1000 queries, up to 10k queries per day.


While logged into Google, navigate to, and click ‘Add’.

You’ll be prompted to configure your custom search engine. Choose a URL (any URL), and give your search engine a name. These values can be anything; for this example, I’ve entered ‘’ and named it ‘Demo’. Click the Create button.

Now click Control Panel to configure your custom search engine and extend it to search the entire web.


You will see a long list of settings related to your new custom search engine. For our purposes you only need to pay attention to the following:

1) Scroll down the page until you see your search engine ID. Note this down, we’ll need it soon:

2) Delete your dummy URL, and toggle on the ‘Search the entire web’ option.

That’s all we need to do here, move on to the next step!


Accessing Google’s Custom Search JSON API requires the use of an API key. To get this 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 it shortly.


Google’s documentation describes how to create an API URL that returns results for the search query you’re interested in.

  • API root:
  • Endpoint: /customsearch/v1
  • Query strings: ?key={API key}&cx={custom search engine ID}&q={search query}
    Query strings example: ?key=AIzaSy…&cx=016496445636816056556:qvzl4ib4xtb
    &q=google tag manager

You can add any of the parameters listed here to further customize your search query:

Putting it together, we get the full API Request URL:
&q=google tag manager


You can now push results from this URL into a database. Google provides documentation and code samples in their developer documentation.

There are no-code options, too:
1) enter this URL into tools like Postman or Swagger Inspector to access search results. Even just entering the URL into a browser will display the API response:

2) paste your URL into Mixed Analytics’ own API Connector, to see the SERP results in Google Sheets. For a more detailed look at this method, please check this post: Build Your Own Search Engine Results Pages (SERP) Dashboard in Sheets.

Whatever the method, the response data will contain a ranking of search results, as well as the URLs, titles, and text snippets that describe the results.


  • As noted above, the search results from the Custom Search JSON API may not exactly match the results from
  • Google will only return 10 results at a time. To retrieve the second set of 10 results, append a ‘start’ parameter, e.g.
    &q=google tag manager&start=11

    To get the third set you’d append &start=21, and so on.

  • Response data from the Google Custom Search API contains nested JSON data, so the output may require some scrubbing to get it into the desired format for analysis. The benefit, of course, is that it’s free 😀

If you want to check out alternatives to Google’s Search API, there are other search API services that provide Google (and other) search engine data in a more convenient format, e.g. these three:

You can also build your own search tools with this great guide to using Python for SEO.

10 thoughts on “Get SEO Data with the Google Custom Search JSON API”

    • Hi Arnaud, this is a web development question so the answer completely depends on what you’re trying to accomplish and the technology behind your website. Generally you’d write some code to parse the JSON response so it can be displayed on your site. Or, if you’re looking for a no-code solution, you can look for a CMS plugin (here’s one for WordPress:, or use an app like to turn your spreadsheet into a website.

      • Hi Ana. Thanks for your answer ! 😉
        I looked into the WP Jason importer but unfortunately I’m not techie enough to implement it till the end… I am actually trying to display Google Custom Search Results only (Say article is speaking about “Paris restaurants close to Eiffel Tower”, I want to display results from predefined search terms such as “Paris+restaurants+Eiffel+Tower” as a side information based on the blog article) on a WP site to give readers further details on a subject.

  1. Hi Ana,
    Great tutorial. Can this fetch method be used with a search box like the one the comes with the google basic CSE?

    • Hey Hassan, do you mean can you get search results for the whole web via a search box? Sure, in that case you’d configure your search engine as described, then click the ‘Add it to your site’ Get Code button to get the code that creates a search box on your site.

    • Hey Artur, sorry, I’m not really sure what you’re trying to do. Is this what you’re looking for?

  2. Hello Ana,
    Such an important article especially for developers. But I want to pay attention that the result of Google CSE is not the same actual Google web search. At this point, we as Aves API, offer the most powerful and affordable SERP API in the market.

    Best Regards,
    Murat Akboğa / Founder, AvesAPI

Comments are closed.