GAQL query builder for the Google Ads API v26
Pick a resource and its fields, add filters and a sort, and the builder checks the query against the v26 field catalog as it is written. Copy it as GAQL, as a curl call to searchStream, or as Python.
Runs in this tab. No login, no developer token and no account connection. Where your data goes
Query check against the Google Ads API v26 field catalog
Passes v26 checks
6 fields from campaign. Fields, filters, sort and limit agree with the catalog. The API has the last word when the query runs.
- Resource
- campaign
- Fields selected
- 6
- Conditions
- 2
- SELECTcampaign.id
- campaign.name
- campaign.status
- campaign.advertising_channel_type
- metrics.cost_micros
- metrics.conversions
- FROMcampaign
- WHERE
- AND
- ORDER BY
- LIMIT
Passes v26 checks
How to read it
The list holds the fields of one resource, grouped as attributes, segments and metrics. Tick a field and it joins SELECT as a numbered line.
Each clause is a band of the sheet. A filter or a sort is edited on its own line, and a line that breaks a rule is marked in the gutter with the reason under it.
The curl and Python faces are the same query, ready for the REST searchStream method and the Python client library. A customer ID typed there stays in the tab.
The rules it checks
Each rule comes from Google’s Google Ads API documentation.
- Every resource, attribute, segment, metric, and enum value is validated against the installed Google Ads API v26 field catalog.OfficialGoogle Ads API v26 Query Language Grammar
- Selecting a core date segment (segments.date, segments.week, segments.month, segments.quarter, or segments.year) requires a finite date filter on segments.date in the WHERE clause (DURING or BETWEEN).OfficialGoogle Ads API v26 Date Ranges
- Queries against change_event require a change_event.change_date_time filter within the last 30 days, require a LIMIT of at most 10,000 rows, and support zero metrics or segments.OfficialGoogle Ads API v26 ChangeEvent Resource
- Every field referenced in ORDER BY must also appear in the SELECT clause and be sortable on the queried resource.OfficialGoogle Ads API v26 Query Structure
The query as files
The query as text, as a shell script that calls searchStream, and as a Python script.
SELECT campaign.id, campaign.name, campaign.status, campaign.advertising_channel_type, metrics.cost_micros, metrics.conversionsFROM campaignWHERE segments.date DURING LAST_30_DAYS AND campaign.status != 'REMOVED'ORDER BY metrics.cost_micros DESCLIMIT 50
# Google Ads API v26 REST searchStream# Replace 1234567890 with your 10-digit customer ID (no dashes).curl -sS -X POST \"https://googleads.googleapis.com/v26/customers/1234567890/googleAds:searchStream" \-H "Authorization: Bearer ${GOOGLE_ADS_ACCESS_TOKEN}" \-H "developer-token: ${GOOGLE_ADS_DEVELOPER_TOKEN}" \-H "Content-Type: application/json" \-d '{"query":"SELECT campaign.id, campaign.name, campaign.status, campaign.advertising_channel_type, metrics.cost_micros, metrics.conversions FROM campaign WHERE segments.date DURING LAST_30_DAYS AND campaign.status != '\''REMOVED'\'' ORDER BY metrics.cost_micros DESC LIMIT 50"}'
from google.ads.googleads.client import GoogleAdsClientclient = GoogleAdsClient.load_from_storage(version="v26")ga_service = client.get_service("GoogleAdsService")query = """SELECT campaign.id, campaign.name, campaign.status, campaign.advertising_channel_type, metrics.cost_micros, metrics.conversionsFROM campaignWHERE segments.date DURING LAST_30_DAYS AND campaign.status != 'REMOVED'ORDER BY metrics.cost_micros DESCLIMIT 50"""stream = ga_service.search_stream(customer_id="1234567890",query=query,)for batch in stream:for row in batch.results:print(row)
What it cannot tell you
- It covers five resources, which are campaign, search_term_view, asset_group, shopping_performance_view and change_event.
- It checks the query against a field catalog and does not run it, so the API has the last word.
- A query that passes here can still return a field compatibility error. Not every pairing the API rejects is in the catalog.
- It holds no developer token and no account. Running the query needs your own API access.
Where your data goes
The query is built and checked in this tab, in your browser’s memory. Nothing is sent to the Google Ads API.
The link you copy holds the query, in the part of the address after the # sign, which a browser does not send when it requests a page. A customer ID is never added to it.
Site analytics are separate from the tool. If you accepted analytics cookies, they record how pages on this site are used, which can include what is on the screen. The privacy policy covers site analytics and your consent settings.
The same reads on live accounts
This builder writes one query for you to run. Parallel AI is the AI agent platform for Google Ads. A Google Ads AI agent runs the reads across every connected account and returns the answer as a Doc or a Sheet, with no query to write.
Questions and answers
What is GAQL?
GAQL is the Google Ads Query Language. A query names the fields to return, one resource to read them from, and optional filters, a sort and a limit. The Google Ads API runs it through the search and searchStream methods.
Which Google Ads API version does the builder use?
Version 26. Field names, types and enum values come from the v26 field catalog, and the curl call targets the v26 searchStream endpoint.
Why does a query with segments.date need a date filter?
Selecting a date segment such as segments.date asks for a row for each day, so the API requires a finite date range in WHERE. Add segments.date DURING LAST_30_DAYS, or a BETWEEN range.
What does a change_event query require?
A change_event query needs a filter on change_event.change_date_time within the last 30 days and a LIMIT of 10,000 or less. It takes no metrics or segments.
Does the builder send the query anywhere?
No. The query is built and checked in the browser tab. Nothing is sent to the Google Ads API, and no customer ID is added to the link.
Skip the query and ask for the answer
Connect Google Ads and Parallel AI reads the account through the Google Ads API for you, across your connected accounts, and delivers the result as a Doc or a Sheet.
Starter $20, Pro $60 and Max $200 a month
You add a card to start the trial, then connect Google Ads.