This guide contains examples of calling the REST endpoints directly, without the use of a client library.
Prerequisites
All the samples below are meant to be easily copy-and-pasteable into a bash shell using curl command. You will need a Search Ads 360 manager account containing at least one client account.
Environment variables
Enter account credentials and IDs below, and then copy-and-paste into your terminal to configure the environment variables used in the subsequent examples.
API_VERSION="0"
OAUTH2_ACCESS_TOKEN="OAUTH_ACCESS_TOKEN"
MANAGER_CUSTOMER_ID="MANAGER_CUSTOMER_ID"
CUSTOMER_ID="CUSTOMER_ID"
Additional optional object IDs
The following examples work on pre-existing campaigns. If you have IDs of an existing campaign to use with these examples, enter it below.
CAMPAIGN_ID=CAMPAIGN_ID
Paginated search
The search
method uses pagination, with an adjustable pageSize
parameter
specified alongside the query
.
cURL
#!/bin/bash # [START curl_command] curl -f --request POST "https://searchads360.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/searchAds360:search" \ --header "Content-Type: application/json" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "pageSize": 10, "query": " SELECT campaign.name, campaign_budget.amount_micros, campaign.status, campaign.advertising_channel_type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.bidding_strategy_type FROM campaign WHERE segments.date DURING LAST_7_DAYS AND campaign.status != 'REMOVED' " }' # [END curl_command]
SA360 Query Language
SELECT campaign.name, campaign_budget.amount_micros, campaign.status, campaign.advertising_channel_type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.bidding_strategy_type FROM campaign WHERE segments.date DURING LAST_7_DAYS AND campaign.status != 'REMOVED'
Streaming
The searchStream
method streams all results in a single response, and thus the
pageSize
field is not supported.
cURL
#!/bin/bash # [START curl_command] curl -f --request POST "https://searchads360.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/searchAds360:searchStream" \ --header "Content-Type: application/json" \ --header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \ --header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \ --data '{ "query": " SELECT campaign.name, campaign_budget.amount_micros, campaign.status, campaign.advertising_channel_type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.bidding_strategy_type FROM campaign WHERE segments.date DURING LAST_7_DAYS AND campaign.status != 'REMOVED' " }' # [END curl_command]
SA360 Query Language
SELECT campaign.name, campaign_budget.amount_micros, campaign.status, campaign.advertising_channel_type, metrics.clicks, metrics.impressions, metrics.ctr, metrics.average_cpc, metrics.cost_micros, campaign.bidding_strategy_type FROM campaign WHERE segments.date DURING LAST_7_DAYS AND campaign.status != 'REMOVED'