API stands for Application Programming Interface. It’s like a bridge between two software programs that allows both of them to connect to share data and achieve a certain level of integration between the two programs. Here you will learn the techniques of Google Indexing API Python.
- You need to install Python, Anaconda on Windows/Mac
- Need to have a Google Developer Console account
- Need to set a billing account on the Google Developer Console settings (Optional)
From Google Developer Console dashboard > go to Select a project > New Project > Give Project Name > Click on Create’, as shown here.
A notification will appear instantly and then click on SELECT PROJECT as shown here:
Thereafter select API & Services > Credentials
Then click on Create Credentials
Next, select Service Account
Fill the Service account name and description fields
Then click on Create and Continue button
Next, Select Role to Owner and click > continue > done as shown below:
Once the complete setup is done, then copy the marked generated email to a notepad for future use:
Then click on this marked email and add key as shown below:
Then select JSON and click on Create
A private key will be saved on your computer automatically.
Now, let’s move on to enabling the API part. Here are the steps to consider:
Click on left hamburger menu > APIs & Services > Library
Then search indexing api on the library.
Select the 1st One as shown here:
And click on Enable option
This is the entire Google Developer Console steps to consider. Now we need to head on to the Google Search Console property of the particular website.
First up, go to settings.
Then select Users and Permissions
Click on ADD USER
Now add the generated mail which we got from Google Developer Console and set the permission to owner
Once you are done with this, then head over to the Anaconda console, to run the command as shown below:
Code 1: pip install oauth2client httplib2
Code 2: pip install pandas
Here we need to install some library files through the Anaconda terminal, as shown below:
Code 1 initialization done
Code 2 initialization done
Now just check the current index status for the site you are expecting to index on Google.
Current discovered URLs on Google: 16
Also, check some of the key pages for the site that are not being indexed yet by Google. For example, see this below:
And based on these searches, make a comprehensive list of URLs that you want to index on Google and save it in a CSV file (data.csv)
Then create a folder consisting of 3 files, one is data.csv (the list of URLs), another one is apidetails.json (rename with this name) that is generated previously by Google Console Developer and the last file is the indexing.py code snippet file.
Once you are ready with all the files then we need to finally run the indexing script through the terminal as shown here:
Let’s run the code of indexing.py.
We re-run the Anaconda Console and change the path of the respective directory by putting the below syntax as shown in the screenshot below:
After changing the path we run the following code as below:
Code to execute: python indexing.py
Once you run the code Google will get the indexing request for the specified URLs with timestamps as shown in the above screenshot.
Sidenote: Here you can add up to 1000 URLs quota per campaign to make the bulk indexing request.
Results we got after implementation:
As per the indexing status of the URL (https://sustainergyholding.com/faq/) it was not indexed in the Google SERP to date (16.02.2022). After running the Python SEO program for this website, the URL got indexed as shown below (17.02.2022):
By implementing this procedure, we can enhance the link indexing possibility to a great extent and as per the case study shown here, it is quite effective.