Overview
The Search Console client provides methods to fetch comprehensive search performance data from Google Search Console API v1. It handles authentication, rate limiting, and error recovery automatically.Installation
Class: SearchConsoleClient
getPerformanceData()
Fetches comprehensive performance data for a specified date range.siteUrl- Full site URL with protocol (e.g.,https://example.com/)accessToken- Valid Google OAuth access tokenstartDate- Start date inYYYY-MM-DDformatendDate- End date inYYYY-MM-DDformat
ReportGenerationError with:
401- Authentication expired, requires reauthentication403- API quota exceeded429- Rate limit exceeded (retryable)500+- Server errors (retryable)
getTopKeywords()
Fetches top performing keywords for the last 30 days.siteUrl- Full site URL with protocolaccessToken- Valid Google OAuth access tokenlimit- Number of keywords to return (default: 10)
getTopPages()
Fetches top performing pages from organic search.siteUrl- Full site URL with protocolaccessToken- Valid Google OAuth access tokenlimit- Number of pages to return (default: 10)
getPerformanceComparison()
Compares performance between two time periods.getDailyPerformanceData()
Fetches daily time-series data for charts.getKeywordPageMapping()
Fetches keyword-to-page relationships for cross-referencing with Analytics.getVerifiedSites()
Lists all verified sites accessible to the user.['https://example.com/', 'sc-domain:example.com'])
Example:
validateSiteAccess()
Validates that a site URL is accessible with current credentials.true if site is accessible, false otherwise
Static Methods
formatSiteUrl()
Formats a domain string into a valid Search Console site URL.Error Handling
All methods use automatic retry with exponential backoff for transient errors:- Maximum 3 retry attempts
- Exponential backoff: 1s, 2s, 4s (with jitter)
- Only retries on 429 (rate limit) and 5xx errors
- Immediately fails on 401 (auth) and 403 (quota)
Rate Limiting
Google Search Console API quotas:- Requests per day: 2,000 per project
- Requests per 100 seconds: 1,200 per project
- Queries per day (per property): Unlimited
- Batch related queries using
Promise.all() - Cache results when possible
- Use date ranges efficiently (max 16 months)
- Handle 429 errors with exponential backoff
Authentication
Requires Google OAuth 2.0 with the following scope:Date Formats
All date parameters use ISO 8601 format:YYYY-MM-DD
Valid Examples:
2026-03-012026-01-15
03/01/2026(US format)2026-3-1(missing leading zeros)2026-03-01T00:00:00Z(includes time)