{"id":29373965,"url":"https://github.com/rakeshgunduka/gaapi","last_synced_at":"2025-07-09T19:40:46.724Z","repository":{"id":57432844,"uuid":"144469951","full_name":"rakeshgunduka/gaapi","owner":"rakeshgunduka","description":"A light weight python wrapper for Google's Analytics Reporting API v4","archived":false,"fork":false,"pushed_at":"2021-08-04T18:47:32.000Z","size":19,"stargazers_count":9,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-02T11:54:25.093Z","etag":null,"topics":["cache","google","google-analytics","google-api"],"latest_commit_sha":null,"homepage":"https://gaapi.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rakeshgunduka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-12T13:41:57.000Z","updated_at":"2023-11-09T12:58:52.000Z","dependencies_parsed_at":"2022-08-27T20:51:14.236Z","dependency_job_id":null,"html_url":"https://github.com/rakeshgunduka/gaapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rakeshgunduka/gaapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshgunduka%2Fgaapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshgunduka%2Fgaapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshgunduka%2Fgaapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshgunduka%2Fgaapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rakeshgunduka","download_url":"https://codeload.github.com/rakeshgunduka/gaapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rakeshgunduka%2Fgaapi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263305980,"owners_count":23445954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","google","google-analytics","google-api"],"created_at":"2025-07-09T19:40:45.747Z","updated_at":"2025-07-09T19:40:46.603Z","avatar_url":"https://github.com/rakeshgunduka.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gaapi 0.1.5\n\nA light weight python wrapper for [Google's Analytics Reporting API v4](https://developers.google.com/analytics/devguides/reporting/core/v4/) written upon [Google's API Python Client](https://github.com/google/google-api-python-client).\n\n# Features provided by Gaapi\n- Analytics focussed library to handle reporting api.\n- Pythonic style usage.\n- Enables you to cache your response data.\n- Enables you to get simplified response data. (TO-DO)\n\n# Installation\nTo install, simply use `pip` or `easy_install`:\n\n```bash\n$ pip install --upgrade gaapi\n```\nor\n```bash\n$ easy_install --upgrade gaapi\n```\n\n# Acquire Google credentials\n\n**1.  To create a Service Account Credentials, follow the below link**\n\nhttps://support.google.com/a/answer/7378726?hl=en\n\n**2.  Get view ID in Google Analytics, follow the below link**\n\nhttps://keyword-hero.com/documentation/finding-your-view-id-in-google-analytics\n\n------------\n\n# Get Started\n#### Instanstiate GA Client\n\n    from gaapi import Client\n\n    GA_SERVICE_ACCOUNT_CREDENTIALS = {\n       \"type\": \"service_account\",\n       \"project_id\": \"analytics-xyz\",\n       \"private_key_id\": \"private_key_id\",\n       \"private_key\": \"-----BEGIN PRIVATE KEY-----ASADASDONWQENLKQWEIL\\nASDASDOILWQE\",\n       \"client_email\": \"username@analytics-xyz.iam.gserviceaccount.com\",\n       \"client_id\": \"103486406559549721528\",\n       \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n       \"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\n       \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n       \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/username@analytics-xyz.iam.gserviceaccount.com\"\n    }\n    GA_VIEW_ID = '12345567890'\n\n\n    ga = Client(\n            credentials=GA_SERVICE_ACCOUNT_CREDENTIALS,\n            view_id=GA_VIEW_ID\n         )\n\n### Generate Query\n\n    \n#### Gaapi format\n\n    query = ga.query.date_ranges(\n            start_date='2018-07-03', end_date='today'\n        ).metrics(\n            expression='ga:users'\n        ).dimensions(\n            name='ga:pagePath'\n        ).dimensions(\n            name='ga:eventLabel'\n        ).dimension_filter_clauses(\n            filters=[{\n                \"dimension_name\": \"ga:pagePath\",\n                \"operator\": \"REGEXP\",\n                \"expressions\": \".*something.*\"\n            }],\n        )\n\n    # Clone query (Only for Gaapi format)\n    # Add `clean=True` to reset a value in the query (say for date_ranges)\n    cloned_query = ga.query.clone(query).date_ranges(\n             start_date='2018-08-01', end_date='today', clean=True\n        )\n\n    # Read query\n    print(query.json())\n\n\n#### Python Dictionary format\n    query = {\n        'date_ranges': {\n            'start_date': '2018-07-03',\n            'end_date': 'today'\n        },\n        'metrics': [\n            {'expression': 'ga:users'}\n        ],\n        'dimensions': [\n            {'name': 'ga:pagePath'}\n        ],\n        'dimension_filter_clauses': [{\n          \"filters\": [{\n              \"dimension_name\": \"ga:pagePath\",\n              \"operator\": \"REGEXP\",\n              \"expressions\": \"\\/.*something\\/.*\"\n          }]\n        }]\n    }\n\n#### Google's original query format\n    query = {\n        'dateRanges': {\n            'startDate': '2018-07-03',\n            'endDate': 'today'\n        },\n        'metrics': [\n            {'expression': 'ga:users'}\n        ],\n        'dimensions': [\n            {'name': 'ga:pagePath'}\n        ],\n        'dimensionFilterClauses': [{\n          \"filters\": [{\n              \"dimensionName\": \"ga:pagePath\",\n              \"operator\": \"REGEXP\",\n              \"expressions\": \"\\/.*something\\/.*\"\n          }]\n        }]\n    }\n\n\n\n#### Request Data\n\n    # Using gaapi query or python dictionary or json\n    response = ga.batch_get(query)\n    \n    # Cache for 600ms\n    response = ga.batch_get(query, cache_ttl=600)\n\n------\n\n## Third Party Libraries and Dependencies\nThe following libraries will be installed when you install the client library:\n* [google-api-python-client](https://github.com/google/google-api-python-client) (Google Client Library)\n* [google-auth](https://github.com/GoogleCloudPlatform/google-auth-library-python/) (Google Auth Library)\n* [walrus](https://github.com/coleifer/walrus) (Light weight Caching Library)\n\n## To-Dos\n- Response Object Manipulation. (This update will enable to you to generate response in Google Raw Response, Simplified Response, CSV, Panda Dataframe).\n- Test cases.\n\n## Contribute\n1. Look for an open [issue](https://github.com/rakeshgunduka/gaapi/issues) or create new issue to get a dialog going about the new feature or bug that you've discovered.\n2. Fork the [repository](https://github.com/rakeshgunduka/gaapi) on Github to start making your changes to the master branch (or branch off of it).\n3. Write a test which shows that the bug was fixed or that the feature works as expected.\n4. Make a pull request.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakeshgunduka%2Fgaapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frakeshgunduka%2Fgaapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frakeshgunduka%2Fgaapi/lists"}