3 horizontal lines, burger
3 horizontal lines, burger
3 horizontal lines, burger
3 horizontal lines, burger

3 horizontal lines, burger
Remove all
LOADING ...

Content



    Connecting to GSC API via python

    Clock
    27.09.2026
    /
    Clock
    27.09.2026
    /
    Clock
    2 minutes
    An eye
    75
    Hearts
    0
    Connected dots
    0
    Connected dots
    0
    Connected dots
    0
    Tags:
    Python
    Google

    API Integration

    Here’s how to access the Google Search Console API, what you’ll need, and why it’s useful. To start, I’m sending you to another site: https://console.cloud.google.com/. This is where we’ll create a dedicated project and enable the relevant API for Google Sheets. Naturally, you’ll need a Google account to sign in.
    Next, you’ll need to create a “project.” You can do this by pressing Ctrl+O or by following the steps shown in the image:
    Please don't forget to navigate to the previously created project by clicking on its name. After that, you will need to enable the required API from the library: the Google Search Console API.
    Let's find the required API using the search function—type "search console." You will see a single option; click on it and activate it:
    After clicking, you will be redirected to the management page for this API. All that remains is to create the appropriate access keys and download them. To do this, click the “+ Create credentials” button and select “Service Account”.
    You will be redirected to a new page, where you will need to name this standalone account and grant the appropriate permissions to edit the spreadsheets.
    There’s just a little bit left. Generate the key and download it.
    Once you have the key, you also need to grant access to Google Search Console for the service email address. Copy the address and go to the site settings in Google Search Console.
    Now, any Python script with access to the previously downloaded credentials file will have access to your Google Search Console account.

    Using the API in the script

    To do this, install the following packages in your virtual environment:
    pip install google-api-python-client google-auth pandas
    Next, to demonstrate how to connect to the API, I will show an example function:
    from google.oauth2 import service_account from googleapiclient.discovery import build def fork_with_gsc(): # Load credentials credentials = service_account.Credentials.from_service_account_file( "./credentials.json", scopes=['https://www.googleapis.com/auth/webmasters.readonly'] ) # Using v1 version of API Search Console service = build('searchconsole', 'v1', credentials=credentials) request_body = { 'startDate': "16-06-2026", 'endDate': "30-06-2026", 'dimensions': ['page'], 'rowLimit': 25000, 'startRow': 0 } # Send the request response = service.searchanalytics().query( siteUrl='sc-domain:timthewebmaster.com', body=request_body ).execute() rows = response.get('rows', [])
    In other words, the file containing the required details is first loaded into memory, followed by a request with the necessary parameters to retrieve the required data. Full documentation from Google on what to send and how to interact with GSC can be found on this page.

    Do not forget to share, like and leave a comment :)

    Comments

    (0)

    captcha
    Send
    LOADING ...
    It's empty now. Be the first (o゚v゚)ノ

    Other

    Similar articles


    React and Django REST API. How to integrate one into another and how to use

    Clock
    24.07.2024
    /
    Clock
    12.09.2026
    An eye
    783
    Hearts
    0
    Connected dots
    0
    Connected dots
    0
    Connected dots
    0
    In this article, I will describe a process of integrating the React framework with the Django website. We will configure a communication API between both of them. Also, a TailwindCSS …

    An example of the integration of Django with allauth. Frontend on ReactJS

    Clock
    31.01.2025
    /
    Clock
    12.09.2026
    An eye
    3821
    Hearts
    0
    Connected dots
    0
    Connected dots
    0
    Connected dots
    1
    In this article I will describe the process of integrating allauth into a Django project. Frontend is handled by React. I will configure a registration and an authorization process by …