Back to blog
google-search-consoleapijson-exportpython

How to Export Google Search Console Data to JSON (API & Script Guide)

Isaac Gounton·

Why Export Search Console to JSON?

The standard Google Search Console web interface only exports to CSV and Google Sheets — both truncated at 1,000 rows. If you are building automated data pipelines, feeding data to AI coding agents, or loading search records into a document database (such as MongoDB or PostgreSQL jsonb), you need structured JSON payloads.

This guide covers how to query the Google Search Analytics API and export clean, multi-dimensional JSON records.


1. The API Query Payload

To extract performance data via JSON, send an authenticated POST request to: https://www.googleapis.com/webmasters/v3/sites/{siteUrl}/searchAnalytics/query

Sample Request Payload (request.json)

{
  "startDate": "2026-07-01",
  "endDate": "2026-07-31",
  "dimensions": ["date", "query", "page", "device", "country"],
  "type": "web",
  "aggregationType": "auto",
  "rowLimit": 25000,
  "startRow": 0
}

2. API Response JSON Structure

The API returns a structured JSON object containing an array of rows. Each entry contains your selected dimension keys alongside aggregated performance metrics:

{
  "rows": [
    {
      "keys": [
        "2026-07-15",
        "strategic seo audit",
        "https://dadseo.com/blog/what-is-strategic-seo-audit",
        "DESKTOP",
        "usa"
      ],
      "clicks": 48,
      "impressions": 512,
      "ctr": 0.09375,
      "position": 3.4
    },
    {
      "keys": [
        "2026-07-15",
        "gsc 16 month data retention",
        "https://dadseo.com/blog/gsc-data-retention-explained",
        "MOBILE",
        "gbr"
      ],
      "clicks": 21,
      "impressions": 340,
      "ctr": 0.06176,
      "position": 4.1
    }
  ],
  "responseAggregationType": "byPage"
}

3. Python Script to Export JSON to File

Use this automated script to fetch data and write it directly to a local .json file:

import json
import os
from google.oauth2 import service_account
from googleapiclient.discovery import build

def export_gsc_to_json(property_uri, start_date, end_date, output_file):
    # Authenticate via service account
    SCOPES = ['https://www.googleapis.com/auth/webmasters.readonly']
    creds = service_account.Credentials.from_service_account_file(
        'credentials.json', scopes=SCOPES
    )
    service = build('searchconsole', 'v1', credentials=creds)

    request_body = {
        'startDate': start_date,
        'endDate': end_date,
        'dimensions': ['date', 'query', 'page', 'country', 'device'],
        'rowLimit': 25000
    }

    response = service.searchanalytics().query(
        siteUrl=property_uri, body=request_body
    ).execute()

    with open(output_file, 'w', encoding='utf-8') as f:
        json.dump(response, f, indent=2, ensure_ascii=False)

    print(f"Successfully exported {len(response.get('rows', []))} rows to {output_file}")

# Example invocation:
# export_gsc_to_json('https://example.com/', '2026-08-01', '2026-08-27', 'gsc_dump.json')

Weighing JSON Against Your Other Options

JSON via the API isn't the only way to get this data out — see the full CSV vs. JSON vs. BigQuery comparison for when to reach for a bulk export or a managed sync instead.

For complete documentation on programmatic access, see the DadSEO API Reference.

IG
Isaac Gounton

Founder of DadSEO. I build tools that turn SEO data into strategy — not scores. Previously spent years running audits that told me what was broken without telling me what mattered.

Read more about me →

Ready to see what your SEO data actually means?

DadSEO connects to Google Search Console and gives you a strategic diagnosis — threats, gaps, and opportunities ranked by impact.

Get Your Free Audit