Skip to main content

A simplified package for Google Search Console API

Project description

A simplified, object-oriented helper library for the Google Search Console API. This package only covers basic API calls and was mainly created for practice purposes. To get the full Google Search Console API experience see Josh Carty's python wrapper.

Getting Started

Install the library on your local machine.

pip3 install gsclight

Use a Google account to create application credentials, download the JSON file and put it in the same directory as your script with the name client_secret.json. Every execution of any API-dependent library code,will prompt to perform the auth flow.

from gsclight import oauth

CLIENT_SECRET = "../client_secret.json"
AUTH_SCOPE = "https://www.googleapis.com/auth/webmasters.readonly"
account = oauth.authenticate_to_gsc(CLIENT_SECRET, AUTH_SCOPE)

Use the Google Search Console wrapper to get an overview of all sites your personal account has access as well as all sites your account is verified for (meaning you can request data via the API).

account.list_all_urls()
account.list_verified_urls()

To access data programmatically via the API specify the URI, date range as well as the dimensions your report should contain (metrics always consist of clicks, impressions, ctr and position). Filters are currently not implemented. The row limit is set to 25,000 rows and can not be adjusted. If you exceed the row limit try to request smaller chunks of data (e.g. apply smaller date range). Per default the search type web is used, but this can be adjusted to image or video.

report, dimensions = account.get_data('https://www.my-website.com/', "2019-09-02", "2019-09-03", 'date', 'device')

In order to use the Google Search Console API response for further analysis the library comes with a built-in function to parse the reports to human-readable dataframes.

from gsclight import parse_report as p
df = p.parse_report(report, dimensions)

df.head()

Authentication & Client Secrets

This library currently only supports user-based OAuth crendentials. Service accounts can not be used.

The Google OAuth flows requires you to provide a client id and secret in the from of a JSON file. You can create these in any Google Cloud or Google Developer project:

  1. Open the Google API Console Credentials page.
  2. Optional: From the project drop-down, choose Create a new project, enter a name for the project, and optionally, edit the provided Project ID. Click Create.
  3. On the Credentials page, select Create credentials, then select OAuth client ID.
  4. Select Other for the Application type, and enter any additional information required.
  5. Click Create.
  6. On the page that appears, you can download client id and secret as a JSON file.

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

gsclight-0.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

gsclight-0.0.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file gsclight-0.0.1.tar.gz.

File metadata

  • Download URL: gsclight-0.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.4

File hashes

Hashes for gsclight-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f041aa92be7b7f40070cb2971ec6a918539199b2aa45664bc19433c0942e6e3c
MD5 5c766428f7aeca41e0e5a9ccce7974c4
BLAKE2b-256 a5a18629feee9f53f43173c70e003ddcbb5c3bf97219f08cb37b4a31f1ffa148

See more details on using hashes here.

File details

Details for the file gsclight-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: gsclight-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.4

File hashes

Hashes for gsclight-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 052c97b198d852db7898887d3a712a6c0748bc4200c0cacc0ea467389eb10bba
MD5 a952ea5f156b037aa710b18f6cba5485
BLAKE2b-256 343c13f893585a74121e362e2a308030b70c9f9c0ab4658e6a42088535da6779

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