Back

Google Search Console API Essential Guide

Aug 3, 20246 minute read

What type of API does Google Search Console provide?

Based on the search results, Google Search Console uses a REST API. Here are the key points:

Type of API

Google Search Console uses a REST API. The API operations map directly to REST HTTP verbs, and the URIs follow a typical REST format:

VERB https://www.googleapis.com/webmasters/v3/resourcePath?parameters

Key Characteristics

  • Uses standard HTTP methods (GET, POST, etc.) to perform operations
  • Resources are accessed via URIs
  • Likely uses JSON for data formatting (common for REST APIs, though not explicitly stated)

Authentication

  • Requires OAuth 2.0 credentials for most endpoints
  • Some endpoints like Testing Tools API may not require OAuth2

Usage

  • Developers need to create a project and credentials in the Google API Console before using the API
  • The API documentation assumes familiarity with Google Search Console and web programming concepts

Comparison to Other API Types

While Google Search Console uses REST, it's worth noting the differences with other API types:

  • SOAP: Uses XML, more rigid structure, better for enterprise environments
  • GraphQL: Allows more flexible querying, good for complex data requirements
  • gRPC: Designed for high performance and scalability

REST was likely chosen for Google Search Console due to its simplicity, wide support, and suitability for web and mobile applications.

In summary, Google Search Console provides a REST API for developers to interact with its services programmatically.

Does the Google Search Console API have webhooks?

Based on the search results provided, it does not appear that the official Google Search Console API has webhooks or an event subscription system. The search results do not contain any information specifically about the Google Search Console API or webhooks for it.

However, I can provide some relevant information about webhooks and event subscriptions for other Google services:

Google Workspace Events API

Google offers an Events API for Google Workspace that allows subscribing to events across Google Workspace applications. Key points include:

  • It uses Google Cloud Pub/Sub topics as the notification endpoint to receive events.
  • Events represent changes to Google Workspace resources, such as when resources are created, updated, or deleted.
  • Events are encoded as Google Cloud Pub/Sub messages.

Webhook Trigger in Google Cloud

Google Cloud offers a Webhook trigger feature as part of its Application Integration service. This allows you to:

  • Configure webhooks to trigger integrations based on events.
  • Set up authentication for the webhook listener.
  • Specify event type field location and name.

Best Practices

When working with webhooks and event subscriptions:

  1. Use appropriate authentication methods to secure your webhook endpoints.
  2. Handle potential failures and implement retry logic.
  3. Process events asynchronously to avoid blocking the webhook receiver.
  4. Implement proper error handling and logging.

While these features are not specifically for the Google Search Console API, they demonstrate Google's support for webhooks and event-driven architectures in other services. If you need real-time updates from Google Search Console, you may need to explore alternative solutions or periodically poll the API for changes.

Rate Limits and other limitations

Here are the key API rate limits for the Google Search Console API:

General Limits

  • Per-user limit: 20 queries per second (QPS), 200 queries per minute (QPM) [1]
  • Per-project limit: 100,000,000 queries per day (QPD) [1]

Search Analytics Resource Limits

  • Per-site quota: 1,200 QPM [1]
  • Per-user quota: 1,200 QPM [1]
  • Per-project quota: 30,000,000 QPD, 40,000 QPM [1]

URL Inspection Limits

  • Per-site quota: 2,000 QPD, 600 QPM [1]
  • Per-project quota: 10,000,000 QPD, 15,000 QPM [1]

Data Limits

  • Maximum of 50,000 rows of data per day per search type (web, image, etc.) [2]

Key Points to Consider

  • There are both short-term (10 minute) and long-term (1 day) load quotas for Search Analytics queries [1]
  • Queries grouped/filtered by page and/or query string are more expensive in terms of quota [1]
  • Longer date ranges increase query load [1]
  • The API has a "quota exceeded" error for all quota exceeded events [1]

Best Practices

  • Spread out queries throughout the day to avoid exceeding short-term quotas [1]
  • Avoid requerying the same data repeatedly [1]
  • Remove grouping/filtering by page and/or query string to reduce load for expensive queries [1]
  • Use shorter date ranges when possible to reduce query load [1]
  • Implement proper error handling and backoff strategies for quota exceeded errors [4]
  • Consider using batching for large amounts of data, but be mindful of the 1,200 queries per minute limit [4]

By understanding and adhering to these rate limits, you can effectively use the Google Search Console API while avoiding quota issues and ensuring smooth operation of your applications.

Latest API Version

The most recent version of the Google Search Console API is v1. Here are the key points:

  1. The current version of the Google Search Console API is v1 [1].

  2. Google has been working to upgrade the infrastructure of the Search Console API, but the API itself remains backward compatible with no changes in scope or functionality [2].

  3. Key changes to be aware of:

    • There are changes to how API usage is reported in Google Cloud Platform dashboards [2].
    • If you have API key restrictions set up, you may need to update them [2].
    • If you're using third-party API libraries or querying the Webmasters Discovery Document directly, you'll need to update by the end of the year [2].
  4. The API provides programmatic access to Search Console data, allowing developers to query things like search analytics, sitemaps, and crawl errors [1].

  5. Best practices:

    • Monitor your API usage on the new Google Search Console API page in Google Cloud Console [2].
    • If you have API key restrictions, make sure the Search Console API is not restricted [2].
    • Stay updated on any announcements from Google regarding changes or updates to the API [2].

While Google has made infrastructure upgrades, the core API version (v1) and functionality remain the same. Developers should be aware of the changes in reporting and potential need to update API key restrictions or discovery document usage.

How to get a Google Search Console developer account and API Keys?

1. Create a Google Cloud Project

  • Go to the Google Cloud Console (https://console.cloud.google.com/).
  • Create a new project or select an existing one.

2. Enable the Google Search Console API

  • In your Google Cloud project, go to "APIs & Services" > "Library".
  • Search for "Google Search Console API" and "Indexing API".
  • Enable both APIs for your project.

3. Set up OAuth 2.0 credentials

  • Go to "APIs & Services" > "Credentials".
  • Click "Create Credentials" and select "OAuth client ID".
  • Choose the appropriate application type (e.g., Web application, Desktop app).
  • Download the JSON file containing your client ID and client secret.
  • Set up the OAuth consent screen in the Google Cloud Console.
  • This screen will be shown to users when they authorize your application.

5. Use the correct API scopes

  • For the Google Search Console API, use the following scopes:
    • https://www.googleapis.com/auth/webmasters (read/write access)
    • https://www.googleapis.com/auth/webmasters.readonly (read-only access)

6. Implement OAuth 2.0 authorization flow

  • In your application, implement the OAuth 2.0 authorization flow to obtain access tokens.
  • This typically involves:
    • Redirecting users to Google's authorization server
    • Handling the OAuth callback
    • Exchanging the authorization code for access and refresh tokens

What can you do with the Google Search Console API?

Here are the key data models you can interact with using the Google Search Console API, along with what is possible for each:

Search Analytics Data

  • Query search analytics data for your site, including metrics like clicks, impressions, CTR, and position
  • Filter and segment data by dimensions like query, page, country, device, search appearance, and date
  • Group data by property or by page
  • Access up to 16 months of historical data
  • Limited to 50,000 rows of data per day per search type

Sitemaps

  • Submit new sitemaps
  • Delete existing sitemaps
  • List sitemaps submitted for a site
  • Get information about a specific sitemap

Sites

  • Add a new site
  • Verify site ownership
  • Get a list of sites you own/manage
  • Remove a site from your account

URL Inspection

  • Check indexing status and crawling errors for specific URLs
  • View how Google sees the URL (rendered page)
  • Request indexing for a URL

Index Coverage

  • Get data on indexed pages, crawl errors, and excluded pages
  • View reasons for exclusion from the index

Mobile Usability

  • Check for mobile usability issues across your site
  • Get details on specific mobile usability problems

Rich Results / Structured Data

  • View performance and errors for rich results and structured data
  • Get details on specific structured data issues
  • View internal and external links to your site
  • See top linking sites and most linked pages

Security Issues

  • Check for security issues like malware, hacking, etc.
  • Get details on specific security problems detected

Core Web Vitals

  • Access Core Web Vitals data for your site
  • View metrics like LCP, FID, and CLS

Summary

The API provides access to most of the key data available in the Search Console web interface, allowing you to programmatically retrieve and analyze your site's search performance and technical SEO data. The search analytics data is particularly robust, while other areas like sitemaps and URL inspection provide useful site management capabilities.