I Automated Google Index Status Checks for My Blog

I had a long weekend, published multiple articles, and got tired of manually submitting each one to Google Search Console. So I asked AI to write a script that checks the index status of every article in my sitemap and submits the unindexed ones automatically.

I Automated Google Index Status Checks for My Blog
Photo by Emilipothèse / Unsplash

I had a long weekend recently. You know those weekends where you tell yourself you will relax, but instead you end up writing five blog posts? Yeah, that.

Normally, after I publish a post, I go to Google Search Console, paste the URL into the inspection tool, and click "Request Indexing." I do this every time. It takes maybe 30 seconds per post. Not a big deal when you publish once a week. But after a long weekend with multiple posts, it adds up.

I am a DevOps engineer, not an SEO person. I had no idea if Google even had an API for this. I just knew the manual workflow was getting old.

So I asked AI to write the code for me.


I did not know the API existed

Here is the thing. I use Google Search Console almost daily. I inspect URLs, I check performance reports, I look at crawl stats. I have been doing this for months. And somehow I never noticed that there is an API for all of it.

The AI told me there are two APIs I needed:

Search Console URL Inspection API. Checks whether a URL is indexed, when it was last crawled, and if there are any issues. This is the API version of the inspection tool I was using manually.

Indexing API. Submits URLs for indexing. The URL_UPDATED notification type tells Google to re-crawl a page. This is the API version of the "Request Indexing" button.

Honestly, I felt a bit dumb. I had been doing this by hand for months. But in my defense, when you are deep in infrastructure work, you do not think about automating the SEO side of things. You just click the button and move on.

The script the AI wrote

The AI built a Python CLI tool that does three things:

  1. Fetches my sitemap (https://anantafatur.dev/sitemap-posts.xml) and extracts all article URLs
  2. Sends each URL to the Search Console Inspection API to check its index status
  3. Sends the unindexed URLs to the Indexing API to request indexing

I gave it my sitemap URL and my Google service account key. It handled the rest. The code is on GitHub if you want to see it.

The CLI has four commands:

python main.py check        # just inspect, no submission
python main.py submit       # inspect first, then submit unindexed ones
python main.py submit-all   # submit everything regardless of status
python main.py check-submit # same as submit

It also has a --urls-only flag to test the sitemap parsing without making any API calls. I used that first to make sure it was pulling the right URLs before burning quota.

Setting up the Google Cloud side

The AI gave me clear instructions for the setup. I needed to:

  1. Enable both APIs in my Google Cloud project
  2. Create a service account and download the JSON key
  3. Add the service account as an owner of my property in Search Console

The last step matters. The Indexing API requires the service account to be an owner, not just a user with full permissions. I learned that the hard way.

I used the domain property format (sc-domain:anantafatur.dev) because it covers all protocols and subdomains. If you use a URL-prefix property, the API calls need to match that format exactly.

The first run failed

I ran the script for the first time and immediately got an error:

Google Search Console API has not been used in project <project-id>
before or it is disabled.

I had enabled the Indexing API, but I forgot to enable the Search Console API. They are two separate APIs. Two separate toggle switches in the Cloud Console. I only enabled one.

Fixed that, waited a few minutes for propagation, and ran it again.

The actual results

Here is what came back after fixing the matching:

So 45 out of 58 are indexed. 9 are not. 1 threw a server error.

The unindexed ones are mostly older articles. I probably forgot to manually submit them when I published. The one with the server error is my most recent article, published just a day ago. Google might have tried to crawl it while my server was under load. I will re-check it later.

Not great, but also not terrible. I was honestly expecting worse.

Submitting the unindexed ones

The submit command checks all URLs first, then submits only the ones that are not indexed. It uses the Indexing API's URL_UPDATED notification type.

The Indexing API has a quota of 200 URLs per day. My 9 unindexed articles barely make a dent. But if I had 500 articles with 200 unindexed, I would need to spread the submissions across multiple days. The script handles this with a configurable delay between requests.

I did not bother resubmitting the already-indexed articles. Some of them have been updated with better SEO titles, but Google will eventually re-crawl them on its own. For a small personal blog, natural re-crawling is fast enough. I would rather save the quota for new content.


Closing

The AI wrote the whole thing. I gave it my sitemap URL and my service account key, and it built a working CLI tool with four commands, rate limiting, CSV/JSON reports, and proper error handling. I just had to do the Google Cloud setup and catch one string matching bug.

I will probably run this once a month to catch any articles that slipped through. The code is on GitHub if you want to use it. Just replace the sitemap URL and service account key, and you are good to go.

If you are a DevOps person like me who has been clicking buttons in Search Console without thinking about automation, this is your sign. There is an API for that. Or you can just ask AI to write the code. Either way works.