Skip to main content

CLI for Google Search Console

Project description

google-search-console-cli

CLI for Google Search Console using the official Google API Python client.

Highlights

  • Native OAuth login: no mandatory gcloud setup
  • pipx-friendly install (gsc available globally)
  • Site operations: list/get/add
  • Analytics queries by date/query/page with Search Console filters
  • Output formats: table, json, csv
  • Diagnostics: gsc doctor

Install (Recommended)

Install with pipx so gsc is available on your PATH:

pipx install google-search-console-cli

Install From Source

If you cloned this repository and want to run from source, use one of these options.

Option 1: Local virtualenv (best for development)

python3 -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

Fish shell activation:

. .venv/bin/activate.fish

Then run:

gsc --help

Option 2: Install from source with pipx (best for day-to-day CLI usage)

pipx install -e /absolute/path/to/google-search-console-cli

OAuth Setup (Recommended)

Create a Google OAuth client of type Desktop app, then run:

gsc auth login --client-secret /absolute/path/to/client_secret.json

Verify:

gsc auth whoami
gsc doctor

Optional: Set Default Site

gsc config set default-site sc-domain:example.com
gsc config get default-site

After this, you can omit --site in commands that need a property.

Usage

Sites

gsc site list
gsc site get --site sc-domain:example.com
gsc site add --site sc-domain:example.com

Analytics

gsc analytics query \
  --site sc-domain:example.com \
  --start-date 2026-01-01 \
  --end-date 2026-01-31 \
  --dimension date \
  --dimension query \
  --filter query:contains:brand \
  --filter device:equals:MOBILE

Save as CSV:

gsc analytics query \
  --site sc-domain:example.com \
  --start-date 2026-01-01 \
  --end-date 2026-01-31 \
  --dimension page \
  --output csv \
  --csv-path ./analytics.csv

Filter Syntax

Use repeatable filters in this format:

dimension:operator:expression

Supported filter dimensions:

  • country
  • device
  • page
  • query
  • searchAppearance

Supported operators:

  • contains
  • equals
  • notContains
  • notEquals
  • includingRegex
  • excludingRegex

Convenience Script (Repo Local)

If you cloned this repo and want one command setup:

./scripts/setup.sh /absolute/path/to/client_secret.json

Credentials and Config Paths

By default:

  • Credentials: ~/.config/gsc-cli/credentials.json
  • Config: ~/.config/gsc-cli/config.json

Override with env vars:

  • GSC_CREDENTIALS_FILE
  • GSC_APP_CONFIG_FILE
  • GSC_CONFIG_DIR

ADC Fallback (Optional)

If you prefer ADC via gcloud, the CLI still supports it:

gcloud auth application-default login \
  --client-id-file=/absolute/path/to/client_secret.json \
  --scopes=https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/webmasters

Notes

  • Use Search Console property formats like sc-domain:example.com or URL-prefix properties.
  • site add requires write scope (webmasters).
  • analytics query --aggregation-type byProperty cannot be combined with page grouping/filtering.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_search_console_cli-0.1.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_search_console_cli-0.1.0-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file google_search_console_cli-0.1.0.tar.gz.

File metadata

File hashes

Hashes for google_search_console_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 85a2013c795da80258e486351df81aa82fbb8a24a5faaa4d4ccb7eb3097a45ac
MD5 94f406b07e7de3a61beabea5deb1c780
BLAKE2b-256 5c77bcef6928f38f6a1acc35349d641044e6d7e9b038e32cc40c350324530520

See more details on using hashes here.

File details

Details for the file google_search_console_cli-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for google_search_console_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22898a3ca72b61e78305040a44c17eb035ea74dfbf4c72070f1f681c38f1706b
MD5 84ddafa9328464df0d37e60029f4f787
BLAKE2b-256 1e283bbbbe42f8fcb5b210c48747dce243f5238150cbaddfd6f270fb7f231b56

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page