Automatically extract URLs from XML sitemaps and submit them to Google Indexing API.
- Recursively crawls sitemap indexes and nested sitemaps
- Extracts all URLs from XML sitemaps
- Submits URLs to Google Indexing API for faster indexing
- Built-in rate limiting and error handling
- Progress tracking and detailed reporting
- Python 3.7+
- Google Cloud account
- Google Search Console access
- Clone the repository
git clone https://github.com/mrxehmad/google-search-console-indexer.git
cd google-search-console-indexer- Install dependencies
pip install -r requirements.txt- Go to Google Cloud Console
- Click Select a project → New Project
- Enter a project name and click Create
- In your project, go to APIs & Services → Library
- Search for "Web Search Indexing API"
- Click on it and press Enable
- Go to APIs & Services → Credentials
- Click Create Credentials → Service Account
- Fill in the name (e.g.,
sitemap-indexer) and click Create - Skip optional steps and click Done
- Click on the service account you just created
- Go to the Keys tab
- Click Add Key → Create new key
- Choose JSON and click Create
- The file will download automatically
- Rename it to
service-account.jsonand place it in the project root
This step is critical!
- Open your
service-account.jsonfile - Copy the email address from the
client_emailfield - Go to Google Search Console
- Select your property
- Click Settings → Users and permissions → Add user
- Paste the service account email
- Set permission level to Owner
- Click Add
Edit sitemap-indexer.py and update the path to your service account file:
SERVICE_ACCOUNT_FILE = 'service-account.json'You can also adjust:
BATCH_SIZE- Max URLs to process (default: 200)DELAY_SECONDS- Delay between requests (default: 1.0)
Basic usage:
python sitemap-indexer.py -u https://example.com/sitemap.xmlProcess with custom batch size:
python sitemap-indexer.py -u https://example.com/sitemap.xml --batch 100Add delay between requests:
python sitemap-indexer.py -u https://example.com/sitemap.xml --delay 2.0View all options:
python sitemap-indexer.py --help============================================================
Google Sitemap Indexer
============================================================
Service Account: service-account.json
Sitemap URL: https://example.com/sitemap.xml
Batch Size: 200
Delay: 1.0s
============================================================
Processing sitemap: https://example.com/sitemap.xml
Found 3 nested sitemaps
Processing sitemap: https://example.com/sitemap-posts.xml
Found 150 URLs
============================================================
Total unique URLs found: 185
============================================================
[1/185] ✓ Indexed: https://example.com/post-1
[2/185] ✓ Indexed: https://example.com/post-2
...
============================================================
Indexing Summary:
Total URLs: 185
Successfully indexed: 183
Failed: 2
============================================================
403 Forbidden / Permission Denied
- Ensure service account email is added as Owner in Search Console (not just User)
API Not Enabled
- Go to Google Cloud Console and enable "Web Search Indexing API"
File Not Found
- Check the
SERVICE_ACCOUNT_FILEpath in the script
Invalid Credentials
- Re-download the service account JSON key from Google Cloud Console
- Default quota: 200 URLs per day
- You can request quota increases in Google Cloud Console
- The Indexing API is primarily for job postings and livestream videos
- For general pages, regular sitemap submission is recommended
MIT License - see LICENSE file for details
For issues and questions, please open an issue on GitHub or check Google's Indexing API documentation.
