Google Search Console API Setup

This guide walks you through setting up automated GSC data fetching.

Step 1: Enable the API

  1. Go to Google Cloud Console
  2. Create a new project or select existing one
  3. Go to APIs & ServicesLibrary
  4. Search for “Google Search Console API”
  5. Click Enable
  1. Go to APIs & ServicesCredentials
  2. Click Create CredentialsService Account
  3. Name it gsc-reader or similar
  4. Click Create and Continue
  5. Skip role assignment (not needed for GSC)
  6. Click Done
  7. Click on the new service account
  8. Go to Keys tab → Add KeyCreate new key
  9. Choose JSON and download
  10. Rename to service_account.json and place in scripts/gsc/

Step 3: Grant Access in Search Console

  1. Go to Google Search Console
  2. Select your property (360tft.co.uk)
  3. Go to SettingsUsers and permissions
  4. Click Add user
  5. Enter the service account email (from the JSON file, looks like xxx@project.iam.gserviceaccount.com)
  6. Set permission to Restricted (read-only)
  7. Click Add

Step 4: Add Secret to GitHub

  1. Go to your GitHub repo → SettingsSecrets and variablesActions
  2. Click New repository secret
  3. Name: GSC_SERVICE_ACCOUNT
  4. Value: Paste the entire contents of service_account.json
  5. Click Add secret

Step 5: Test Locally

cd scripts/gsc
pip install google-auth google-auth-oauthlib google-api-python-client
python fetch_gsc_data.py --days 7

How It Works

Automated (GitHub Actions)

Manual

# Last 28 days (default)
python fetch_gsc_data.py

# Last 90 days
python fetch_gsc_data.py --days 90

# Specific date range
python fetch_gsc_data.py --start 2025-01-01 --end 2025-01-31

Output

The script generates a JSON report with:

Claude Code Integration

When Claude Code reads scripts/gsc/data/gsc_latest.json, it will:

  1. Identify high-priority opportunities
  2. Suggest specific blog posts or page updates
  3. Recommend meta description improvements
  4. Track progress over time

Troubleshooting

“Permission denied” error

“API not enabled” error

No data returned

File Structure

scripts/gsc/
├── fetch_gsc_data.py      # Main script
├── service_account.json   # Credentials (DO NOT COMMIT)
├── SETUP.md               # This file
└── data/
    ├── gsc_latest.json    # Most recent report
    └── gsc_report_*.json  # Historical reports

Security Notes