{"id":18029291,"url":"https://github.com/gmontamat/pyaw-reporting","last_synced_at":"2025-03-27T03:31:04.369Z","repository":{"id":48429187,"uuid":"49022727","full_name":"gmontamat/pyaw-reporting","owner":"gmontamat","description":"Large scale AdWords reporting tool in Python","archived":false,"fork":false,"pushed_at":"2021-07-26T20:35:01.000Z","size":106,"stargazers_count":12,"open_issues_count":3,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T00:31:55.160Z","etag":null,"topics":["adwords","adwords-api","adwords-reports","awql","googleads","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pyaw-reporting/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmontamat.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":"2016-01-04T20:57:59.000Z","updated_at":"2023-07-25T12:01:43.000Z","dependencies_parsed_at":"2022-08-24T02:50:24.337Z","dependency_job_id":null,"html_url":"https://github.com/gmontamat/pyaw-reporting","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmontamat%2Fpyaw-reporting","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmontamat%2Fpyaw-reporting/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmontamat%2Fpyaw-reporting/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmontamat%2Fpyaw-reporting/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmontamat","download_url":"https://codeload.github.com/gmontamat/pyaw-reporting/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245778433,"owners_count":20670682,"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":["adwords","adwords-api","adwords-reports","awql","googleads","python"],"created_at":"2024-10-30T09:08:44.776Z","updated_at":"2025-03-27T03:31:04.036Z","avatar_url":"https://github.com/gmontamat.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Google Ads Reporting in Python\n\n[![PyPI](https://img.shields.io/pypi/v/pyaw-reporting)](https://pypi.org/project/pyaw-reporting/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/pyaw-reporting)](https://pypi.org/project/pyaw-reporting/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyaw-reporting)](https://pypi.org/project/pyaw-reporting/)\n[![PyPI - License](https://img.shields.io/pypi/l/pyaw-reporting)](https://pypi.org/project/pyaw-reporting/)\n\nAn [AdWords API](https://developers.google.com/adwords/api/docs/guides/start) large scale reporting tool written in\nPython. Reports are downloaded as plaintext files but connectivity with a database engine such as MySQL, PostgreSQL, or\nMongoDB can be implemented [upon request](https://github.com/gmontamat/pyaw-reporting/issues).\n\n## Overview\n\n[pyaw-reporting](https://github.com/gmontamat/pyaw-reporting) is an open-source Python package suitable for large scale\nGoogle Ads reports. Output reports are comma-separated values (CSV) plaintext files. By default, the package uses 10\nthreads to download reports simultaneously from different accounts. The number of threads used can be modified using\nthe `-n` parameter. It has been successfully tested using +100 threads making it useful for heavy load AdWords Manager\nAccounts.\n\n### Supported AdWords API version\n\nThe latest API version supported by this package is\n[v201809](https://ads-developers.googleblog.com/2018/09/announcing-v201809-of-adwords-api.html) with\n[googleads 28.0.0](https://pypi.python.org/pypi/googleads). Older versions of the API are not supported, nor the newer\n[Google Ads API](https://developers.google.com/google-ads/api/docs/start).\n\n## Quick Start\n\n### Prerequisites\n\nYou will need Python 3.6+; this package installs [googleads](https://pypi.python.org/pypi/googleads) as a dependency.\nNote that that support for Python 2.7\n[ended in 2019](https://ads-developers.googleblog.com/2019/10/python-2-deprecation-in-google-ads-api.html). Using a\nvirtual environment is recommended to avoid running the package with `sudo`.\n\nAn access token [YAML file](#about-the-yaml-token) with the corresponding AdWords credentials is also necessary. By\ndefault, the package will look for `~/googleads.yaml` unless a different path is passed. The optional parameter\n**client\\_customer\\_id** must be included in this *YAML* file, you should enter your *AdWords Manager Account id*\n(formerly known as *MCC id*). This way, all accounts linked to the Manager Account will be retrieved. The sample file\n[example.yaml](awreporting/example.yaml) shows how your token should look like.\n\n[AWQL](https://developers.google.com/adwords/api/docs/guides/awql) queries could be either passed in the command line\nwith the `-a`/`--awql` parameter or stored in a plaintext file and passed via the `-q`/`--query` parameter. The module\nincludes a [sample query](awreporting/query.txt) which will retrieve clicks and impressions per ad for the last 7 days.\nRefer to [Report Types](https://developers.google.com/adwords/api/docs/appendix/reports) and\n[The AdWords Query Language (AWQL)](https://developers.google.com/adwords/api/docs/guides/awql) for more information\nabout these queries.\n\n### Installation\n\n```bash\n$ pip install pyaw-reporting\n```\n\n### Usage\n\n#### Command line\n\n```\nusage: awreporting [-h] (-a AWQL | -q QUERY_FILE) [-t TOKEN] [-o OUTPUT]\n                   [-n NUM_THREAD] [-v]\n\nAwReporting - Large scale AdWords reporting tool in Python\n\noptional arguments:\n  -h, --help                              show this help message and exit\n  -t TOKEN, --token TOKEN                 specify AdWords YAML token path\n  -o OUTPUT, --output OUTPUT              define output file name\n  -n NUM_THREAD, --num-thread NUM_THREAD  set number of threads\n  -v, --verbose                           display activity\n\nrequired arguments:\n  -a AWQL, --awql AWQL                    pass AWQL query\n  -q QUERY_FILE, --query-file QUERY_FILE  ...or use a query file\n```\n\nFor example:\n\n```bash\n$ awreporting -t example.yaml -a \\\n  \"SELECT ExternalCustomerId, CampaignId, AdGroupId, Id, Date, Clicks, Impressions \\\n  FROM AD_PERFORMANCE_REPORT WHERE Impressions \u003e 0 DURING LAST_7_DAYS\" \\\n  -o adperformance.csv -n 100\n```\n\nOr, with a query file:\n\n```bash\n$ awreporting -t example.yaml -q query.txt -o adperformance.csv -n 100\n```\n\nIf you experience problems downloading reports, check the resulting logs in `awreporting.log` or use the\n`-v`/`--verbose` parameter to verify if something is wrong with your token or *AWQL* query.\n\n#### Code\n\nIf you prefer embedding this package in your own code, you could do like so:\n\n```python\nfrom awreporting import get_report\n\nquery = (\n    \"SELECT ExternalCustomerId, CampaignId, AdGroupId, Id, Date, Clicks, Impressions \"\n    \"FROM AD_PERFORMANCE_REPORT \"\n    \"WHERE Impressions \u003e 0 \"\n    \"DURING LAST_7_DAYS\"\n)\nget_report('example.yaml', query, 'adperformance.csv', 100)\n```\n\n### About the YAML token\n\nThe example token file provided [example.yaml](awreporting/example.yaml) is not valid. Refer to\n[this guide](https://developers.google.com/adwords/api/docs/guides/first-api-call) if you are using the AdWords API for\nthe first time.\n\n### Disclaimer\n\nThis is neither an official [AdWords API](https://developers.google.com/adwords/api/) repository nor a clone of\n[AwReporting](https://github.com/googleads/aw-reporting). Consider using\n[AwReporting](https://github.com/googleads/aw-reporting) if you are a Java developer. This framework no longer supports\nPython 2.7; only Python 3.6 or greater are compatible since\n[googleads](https://github.com/googleads/googleads-python-lib#python-versions) requires it.\n\n### Troubleshooting\n\nWe recommend that you try the app with a few number of threads first (the default is 10) and increase the amount\naccordingly. The Google Ads server may complain when many API calls are made at the same time, but those exceptions are\nhandled by the app. We have successfully generated huge report files using 200 threads.\n\nWhen using this tool it might be necessary to enable a DNS cache in your system, such as\n[nscd](http://man7.org/linux/man-pages/man8/nscd.8.html). This should eliminate DNS lookup problems when repeatedly\ncalling the AdWords API server. For example, if you find\nmany `URLError: \u003curlopen error [Errno -2] Name or service not known\u003e` in your logs, enable the DNS cache.\n\nIn some Linux systems `nscd` is not enabled by default, but it can be started with:\n\n```\n# systemctl start nscd\n```\n\n## Useful links\n\n* https://developers.google.com/adwords/api/\n* https://github.com/googleads/googleads-python-lib\n* https://github.com/googleads/aw-reporting\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmontamat%2Fpyaw-reporting","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmontamat%2Fpyaw-reporting","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmontamat%2Fpyaw-reporting/lists"}