Automate Google Indexing for Your Website Pages with Python and Google Indexing API

GitHub Repository

Managing a website with numerous pages presents a common issue: not all pages are indexed by Google. A glance at the Google Search Console's pages tab often reveals this discrepancy:

Unindexed Pages Visualization

Notably, some pages remain unindexed due to two main reasons:

  • Crawled — currently not indexed;
  • Discovered — currently not indexed.

To address this, you have a few strategies at your disposal:

Strategy 1: Patiently Await Google's Automatic Indexing

This method can be slow, and there's no guarantee all pages will be indexed. It's impractical for websites with extensive content.

Strategy 2: Manually Submit Pages through Google Search Console

While effective, this approach is labor-intensive, especially for large sites. It involves using the GSC's URL inspection tool for individual page submissions.

URL Inspection Tool in Action

Strategy 3: Automate Indexing with the Google Indexing API

This is the most efficient solution for quickly indexing a large volume of pages. This article focuses on how to utilize this approach.

Understanding the Google Indexing API

Google's Indexing API enables you to notify Google immediately upon creating or updating content, ensuring prompt indexing. We've developed a freely available, open-source Python script that automates page indexing using this API, available in our GitHub Repository.

Implementing the Google Indexing API Python Script

  1. Install Dependencies:
pip install -r requirements.txt
  1. Set Up a Google Cloud Console Project:

Navigate to the Google Cloud Console to create a project.

  1. Generate a Service Account:

Create a service account following these instructions, and download the credentials.json file to your project directory. This account enables indexing of up to 200 pages daily, subject to Google's API constraints.

  1. Grant Service Account Access in Google Search Console:

Add the service account with the Owner role as described here.

  1. Configure the Sitemap URL in
website_sitemap = ''

Adjust this to point to your sitemap. The script processes all pages listed in the sitemap, including those within any sitemap index files.

  1. Execute the Script:

The script can index up to 200 pages per execution, tracking submissions in the urls.json file to avoid duplication. It's designed for daily use to maximize the 200-page daily quota.

Script Execution Output

This method offers a streamlined approach to ensure your website's content is efficiently indexed by Google.