Google Search Results JSON API

SERP i.e Search engine results page is a common term between internet marketers and website owners. For any website, the search traffic is a crucial factor. Search engine optimization or SEO is used to make sure that the web page follows the guidelines laid out by search engines like Google, Yahoo etc to rank better for the keywords.

Google is a widely used search engine and they also provide Google search console where one can view any issues in crawling and other SEO information. However, there is no API which you can use to create your program to track keywords and check rankings. There are many tools and Semrush is the most popular one.

I also used to wonder if there is a way to actually get all the search data in a JSON format so that I can write a small piece of program that handles keyword tracking for me without paying more than $1000/year to any service. Then, I found Serpstack. It provides real-time Google search results in a JSON format.

In this article, I am going to show you how to use this tool to fetch Google search results in a JSON format using an API.

About Serpstack

Serpstack is a service built for developers by the apilayer team. Serpstack provides API which is used by thousands of SEO agencies and marketing professionals to track SERP data of their websites and apps. Serpstack is also used internally by apilayer team to track SERP rankings of their wide range of products.

SERP Stack homepage

Serpstack allows marketers to extract SERP data using custom locations, devices, and languages by just passing extra parameters in their API calls. Serpstack is also used by marketing SaaS startups to deliver search information to their customers. So if you are developing a marketing product and need search results information, give Serpstack a try.

How to use Serpstack

Serpstack provides various plans and it also provides free tier for developers to try it out. You need to create a free account in Serpstack to get the tokens. Click here to create a new free tier account.

SERPStack free account

After creating your account, you should get your API key. Keep it secure and don’t share it with anyone.

Let’s make a test API calls. Open any API simulator like Postman and hit this URL.

http://api.serpstack.com/search?access_key=YOUR_ACCESS_KEY&query=codeforgeek&engine=google&location=newyork&google_domain=google.com

it will return the Google search engine for the keyword “codeforgeek” from new york USA.

serp results

It returns the data in a JSON format which you can later use with any programming language. For example, consider this Node.js code.

const request = require("request");

let options = {
    method: 'GET',
    url: 'http://api.serpstack.com/search',
    qs:
    {
        access_key: 'your access key',
        query: 'codeforgeek',
        engine: 'google',
        location: 'newyork',
        google_domain: 'google.com'
    },
    json: true
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

It’s as simple as the code shown above. Pass your queries and get the result. I am really impressed with the amount of simplicity the Serpstack team has achieved for a complex application like this.

Also, consider this python code.

import requests

url = "http://api.serpstack.com/search"

querystring = {"access_key":"your access key","query":"codeforgeek","engine":"google","location":"newyork","google_domain":"google.com"}

response = requests.request("GET", url, params=querystring)

print(response.text)

Serpstack builds the rock-solid cloud infrastructure to handle billions of API requests. So scaling is never an issue.

Conclusion

I am really impressed with this tool. As a technology architect I understand the amount of work and difficulties the engineers must have faced to build such a simple to use the software. Give this tool a try and let me know how you are using it to build awesome apps.