Skip to main content

A command line interface to the Google Ads Query Language (GAQL). Run with `gaql` or `gaql-tools`

Project description

GAQL CLI

PyPI version PyPI downloads

A CLI for running GoogleAds queries.

Usage

Installing

  • pip install gaql
  • pipx install gaql (recommended)

Querying

The default mode. Runs either as a REPL, or as a one off command

- gaql [ACCOUNT_ID] - run in REPL mode
- gaql [ACCOUNT_ID] [WORDS*] - run a single query. Note depending on your shell you may need to quote some queries if you run like this.

flags:
--help show the help message; basically the below
-f|--format <csv|json|jsonl|proto> specify an output format
-o|--output <file> specify an output file. Based on the extension, format is inferred. Non REPL usage only

Examples, using 1-000-000-000 as our demo account id:

# opens a REPL with json lines as the output format
gaql -f jsonl 1-000-000-000

# runs the query against the given account, outputting to the terminal the results as json lines
gaql -f jsonl 1-000-000-000 'SELECT campaign.id FROM campaign'

# runs the query against the given account, outputting to 'campaigns.jsonl' the result as json lines
gaql -o campaigns.jsonl 1-000-000-000 'SELECT campaign.id FROM campaign'

tip: by default LIMIT 100 will be added to your queries. To override this behavior, simply define your own LIMIT X.

tip: the autocomplete will return only valid fields for the selected entity if you fill out the FROM <entity> part first.

Other tools

Used for useful common queries. Currently only supports getting all accounts under an MCC, to help when managing multiple accounts. The MCC is taken from the login_customer_id field.

  • gaql-tools queries clients

Notes

  • credentials come from the environment > the google .yaml file > a user provided credential file
  • credentials, settings, and history are stored in ./config/gaql/*. The credential file will only be present if you create it through a prompt (i.e you aren't using the ENV, or the YAML file Google specifies)

Ideas / TODO

  • tables as an output format
  • autocomplete for account ids (with caching)

Development

We're using poetry for local development, package management, and publishing. pyenv is recommended for Python version management, and pipx for installation.

Build commands:

make develop - install a development version. run via `poetry run gaql <args>`
make publish - build and distribute to PyPi
make clean   - remove the existing build files
make format  - run black over the code
make lint    - lint and format the code

Security

For sensitive security matters please contact security@getyourguide.com.

Legal

gaql-cli is licensed under the Apache License, Version 2.0. See LICENSE for the full text.

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

gaql-1.11.0.tar.gz (93.1 kB view details)

Uploaded Source

Built Distribution

gaql-1.11.0-py3-none-any.whl (97.0 kB view details)

Uploaded Python 3

File details

Details for the file gaql-1.11.0.tar.gz.

File metadata

  • Download URL: gaql-1.11.0.tar.gz
  • Upload date:
  • Size: 93.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0

File hashes

Hashes for gaql-1.11.0.tar.gz
Algorithm Hash digest
SHA256 55e2c34001eac4b00695a9bc5eab21c04ece1d1b06e25274a7c4f1a5f7b30ee5
MD5 5d5efec52d2a7479a66a2d06bfc10fdd
BLAKE2b-256 9a5b6bbfd9b1c7406cb5a3ef18f8ee179b8c59a26ad27a8a4b00b35cb3928862

See more details on using hashes here.

File details

Details for the file gaql-1.11.0-py3-none-any.whl.

File metadata

  • Download URL: gaql-1.11.0-py3-none-any.whl
  • Upload date:
  • Size: 97.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.4.0

File hashes

Hashes for gaql-1.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6444c86d34288142df45260c3d84f504db9bf810afb485ea4afd8b565cde7a0b
MD5 436e9fc562093654beff18d578ba84e0
BLAKE2b-256 4e1829b3468ee9d195191402fdb5b153c91a3dfedb3f9b545c63ec6b0b3d91d9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page