Skip to main content

Gapy

Gapy is a thin service account client for Google Analytics.

Get set up

First you need to create either a service account or client ID in your Google API Console. If you’re authenticating as a service account you’ll need to download your private key.

If you’re authenticating as a web or installed application you’ll need to download your client secrets file. Use the Google Developers Console to do this:

  • Create a Project for thte application, and add the Analytics API to the Enabled APIs list.

  • In “Credentials”, click “Create new Client ID”.

  • Choose “Installed Application” and type should be “Other”.

  • Once it’s generated your ID, click the new “Download JSON” button and save this file as client_secrets.json.

Then just create a gapy client and start querying.

  • storage_path is the location where you want gapy to keep the storage.db file that it will generate the first time it runs.

  • Ids, metrics and dimensions can be provided as lists or single values.

import gapy.client

# For a service account
client = gapy.client.from_private_key(
    "your account name",
    private_key="your private key",
    storage_path="path/to/storage.db")

# For a web or installed application
client = gapy.client.from_secrets_file(
    "/path/to/client_secrets.json",
    storage_path="/path/to/storage.db")
)


reach_data = client.query.get("12345",
            datetime(2012, 1, 1),
            datetime(2012, 2, 2),
            ['ga:visits', 'ga:visitors'],
            'ga:date')

Google API documentation

This library is a layer over the Google Python API. If you wish to work on it, it may be necessary to consult the Google Analytics API documentation.

Metadata

Release files for gapy 1.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gapy 1.3.6
File Size Uploaded Provenance Actions
gapy-1.3.6.tar.gz 5.3 kB Without provenance Details for gapy-1.3.6.tar.gz

Release files / gapy-1.3.6.tar.gz

Download URL gapy-1.3.6.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f6a095d6615d9ac30514a182dd4b54eee63c3f8220570e5977bab917b58ede27
BLAKE2b-256 checksum
How to use checksums
3bc9c5b3a365dabbe6ce862a15d64d74d5acb12e1d3e9f290bb9d486edf684d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for gapy 1.3.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page