We use cookies

This site uses cookies from cmlabs to deliver and enhance the quality of its services and to analyze traffic..

Where might you have seen our work?
Small places create combinations, but crosses that occur cannot provide many combinations. So be careful in making justifications, especially SEO.

What is Google Search Console API? Learn How to Configure It

Last updated: Jun 08, 2023

What is Google Search Console API? Learn How to Configure It
Cover image: An illustration of the Google Search Console API, which is the medium for connecting configured Google account data.

Disclaimer: Our team is constantly compiling and adding new terms that are known throughout the SEO community and Google terminology. You may be sent through SEO Terms in cmlabs.co from third parties or links. Such external links are not investigated, or checked for accuracy and reliability by us. We do not assume responsibility for the accuracy or reliability of any information offered by third-party websites.

In managing your website, you surely need several supporting tools, such as CMS, Google Data Studio, and Google Search Console.

However, did you know that certain tools, such as Google Search Console, can be customized with certain program codes to make it easier for you to manage your site?

This guide will explain what it means and how to configure the Google Search Console API. Immediately, read the explanation below.

Problems in Google Search Console

google search console user
Figure 1: Illustration of Monitoring Site Performance Using GSC

Basically, Google Search Console, or GSC, has a number of sections. For example, you can focus on the "Performance" report. The "Performance" page can be seen on the GSC dashboard.

When you go to the "Performance" report, data for new queries and pages can be accessed.

Indirectly, this reveals one of the problems or limitations of GSC, namely that the query and the page data are on separate pages.

In other words, if you want to see which queries are ranked for a particular page, this requires you to first click "Pages", select the page, and then click "Back" to return to "Query".

This then creates a poor user experience with a fairly complicated operational method.

Another problem and limitation is when it comes to exporting data.

  • Performance data for queries and pages should be exported separately.
  • Export is limited to 1,000 lines.

However, you can avoid such issues by taking advantage of the Google Search Console API and setting up an easier configuration for yourself.

What is Google Search Console API?

Now, you already know that, basically, Google Search Console has several limitations, including the complexity of connecting query data with page data as well as data export restrictions.

If the UI of Google Search Console represents the factory default view, then the Google Search Console API represents settings that you customize yourself.

Doing this requires a little more effort, but it can give you more control as well as open up more management possibilities, especially in terms of queries and data.

The Google Search Console API is a way to connect to the data in your account, make more customized requests, and get more tailored results.

In fact, with the Google Search Console API, you can bypass factory default settings, such as exports being limited to 1,000 rows, and create configurations that you can customize yourself according to your needs.

4 API Methods for Better Data Analysis

After knowing what the Google Search Console API is, you need to learn about some of the API methods for analyzing data.

Here are four API methods for better data analysis:

1. URL Inspection API

This type of API offers a method for debugging and optimizing certain pages on a website.

This is matched to the index data available in the URL inspection tool, which includes analysis results containing index status, AMP, rich results, and so on.

Large sites, SEO tools, and CMS can use this API to assist users in optimizing sites, monitoring changes, and diagnosing certain problems that may occur with a site.

2. Site API

Site API is a type of API that allows users to add or remove a site in GSC and retrieve information for a specific site.

The site API also allows you to list all of a user's GSC sites and the privacy or permission settings for each one.

It is perfect for CMS implementations, large websites, and SEO agencies that want to manage access more efficiently.

3. Search Analytics API

The Search Analytics API provides data related to the performance of a website in Google search, such as clicks, impressions, and average position, grouped by query, page, country, and so on.

The Search Analytics API offers more data than just a UI or spreadsheet export, with up to 50,000 samples for larger websites.

The Search Analytics API is suitable for companies that want to apply advanced models to analyze the performance of a query or combine data from Google with other sources.

4. Sitemap API

The Sitemap API works by retrieving information about the sitemap submitted to Google Search, such as processing status, last download time, and any warnings.

This type of API can also be used to send and delete sitemaps on a site.

The Sitemap API is suitable for large websites with multiple brands or CMSs that need to manage sitemaps programmatically.

Configuration in Google Search Console API with Node.js

display of site overview on google search console
Figure 2: Site configurable with the Google Search Console API

Basically, the configuration process requires a series of program codes to be implemented.

However, before you start playing with the code, make sure that you have enabled the Google Search Console API for your website or property and set up a service account with the right access credentials to send requests using the GSC API.

Here are the steps to do it:

  • First of all, enable the API in the Google Cloud Console.
  • Afterward, proceed to create a service account in the Google Developers Console.
  • For this newly created service account, open 'Keys', generate a new key, and save the JSON file in a secure directory. Then, the Node.js application will use these credentials to access the API.
  • Add this newly created service account email address as owner in Google Search Console.

Note: Only verified property owners can perform the steps above.

1. Start Configuration

Once you have correctly configured your access credentials, you can immediately begin the initial programming part.

In this section, you must set up authentication and ensure that your credentials are properly configured.

Open a terminal, then start a new node project and install the required packages, including:

  • npm init
  • npm instal googleapis
  • npm instal perpustakaan google-auth

In the same directory, you also need to place the previously created keys.json file. Then, create a new index.js file and use the following code:

const {google} = require('googleapis');
 const {JWT} = require('google-auth-library');
 const searchconsole = google.searchconsole('v1');
  const keys = require('PATH_TO_KEYS.JSON_FILE')
  const client = new JWT({
    email: 'keys.client_email',
    key: 'keys.private_key',
    scopes: ['https://www.googleapis.com/auth/webmasters','https://www.googleapis.com/auth/webmasters.readonly'],
  });
  google.options({auth: client});
// 
      const resSiteList = await searchconsole.sites.list({});
      console.log(resSiteList.data);

cmlabs

If you don't find your property in the list of returned sites, check that you've added your service account to the right property in Google Search Console.

2. Submit New URL for Google Indexing

The second way to configure the Google Search Console API is to submit a new URL so that it will be indexed by Google.

Whether it's a new product page or blog post, you want to make it easy for users to discover it as quickly as possible.

To make this happen, you can follow these steps by submitting an updated sitemap to the sitemap endpoint as an automatic step in a CI/CD workflow.

const res = await searchconsole.sitemaps.submit({
          // The URL of the actual sitemap. For example: `https://namasitusanda.com/sitemap.xml`.
          feedpath: 'placeholder-value',
          // The site's URL, including protocol. For example: `https://namasitusanda.com/`.
          siteUrl: 'placeholder-value',
        });
        console.log(res.data);
      }

cmlabs

3. Checking Whether URL Has Been Indexed or Not

The next way to configure the Google Search Console API is to check whether a URL has been indexed or not.

After you submit your new URL for Google's indexing, the actual site crawl can take up to several weeks.

To avoid manual checking, you can set up a scheduled task to check the status of newly submitted URLs and see if they have been indexed. You can use the following program code:

const resInspectURL = await searchconsole.urlInspection.index.inspect({
     // Request body metadata
     requestBody: {
       // request body parameters
       // {
          "inspectionUrl": "https://namasitusanda.com/blog/nodejs-https-imports",
          "languageCode": "en-US",
          "siteUrl": "https://namasitusanda.com"
       // }
     },
   });
   console.log(resInspectURL.data);

cmlabs

4. Check Click and Impression Changes

The last way to configure the Google Search Console API is to check clicks and impression changes on your site.

If your site has been successfully indexed, you may want to see how the impressions or clicks have changed over time for your recent content. Use the following code to do it:

const resSearchAnalytics = await searchconsole.searchanalytics.query({
        // The site's URL, including protocol. For example: `http://www.example.com/`.
        siteUrl: 'https://namasitusanda.com',
   
        requestBody: {
             "endDate": "2022-03-08",
             "startDate": "2022-03-01",
 "dimensions": ["date"]
        },
      });
      
      console.log(resSearchAnalytics.data.rows);

cmlabs

That was all the discussion about the Google Search Console API, from understanding the types of API to how to configure it.

To help you manage your website, including configuring the Google Search Console, you can use SEO services from cmlabs.

This is because SEO services from cmlabs provide solutions not only to on-page problems but also to off-page, technical, and various other problems.

Our valued partner
These strategic alliances allow us to offer our clients a wider range of SEO innovative solutions and exceptional service. Learn More
cmlabs

cmlabs

WDYT, you like my article?

Need help?

Tell us your SEO needs, our marketing team will help you find the best solution

Here is the officially recognized list of our team members. Please caution against scam activities and irresponsible individuals who falsely claim affiliation with PT cmlabs Indonesia Digital (cmlabs). Read more
Marketing Teams

Agita

Marketing

Ask Me
Marketing Teams

Irsa

Marketing

Ask Me
Marketing Teams

Thalia

Business Development Global

Ask Me
Marketing Teams

Robby

Business Development ID

Ask Me
Marketing Teams

Yuli

Marketing

Ask Me
Marketing Teams

Dwiyan

Business & Partnership

Ask Me
Marketing Teams

Rohman

Product & Dev

Ask Me
Marketing Teams

Said

Career & Internship

Ask Me
notif header image

Get Ahead of the Curve: Introducing Vanguard – Your Passport to Optimaze your Website. For more information, let's talk with our team.

Check

Stay informed with our new tool, cmlabs Surge. Discover popular trends and events!

Check

Your Opinion Matters! Share your feedback in our Plagiarism Checker Survey?

Check

There is no current notification..