Search & SearchStream

The Search Ads 360 Reporting API has a unified attribute retrieval and metrics reporting mechanism that lets you create queries using the Search Ads 360 Query Language. This enables complex queries that can return large quantities of data about individual Search Ads 360 accounts.

You can create queries using either of the Search or SearchStream methods. Both methods support the same queries and return equivalent results. The Search method returns data in customizable page sizes, enabling you to iterate over a result set using pagination. This could be advantageous in low bandwidth or unreliable network conditions, for example, to segment a large result set into smaller responses that can be re-fetched if a connection is lost. The SearchStream method, on the other hand, streams the entire result set back in a single response, which can be more efficient for bulk data retrieval.

Both Search and SearchStream use the same base URL:

    https://searchAds360.googleapis.com/v0/customers/CUSTOMER_ID/searchAds360

The page-based search method takes an optional pageSize parameter which limits how many results are returned in a single API response.

POST /v0/customers/CUSTOMER_ID/searchAds360:search HTTP/1.1
Host: searchAds360.googleapis.com
Content-Type: application/json
Authorization: Bearer ACCESS_TOKEN

{
"pageSize": 10000,
"query": "SELECT ad_group_criterion.keyword.text, ad_group_criterion.status FROM ad_group_criterion WHERE ad_group_criterion.type = 'KEYWORD' AND ad_group_criterion.status = 'ENABLED'"
}

If there are more rows in the results than pageSize, a nextPageToken is returned in the response:

{
  "results": [
    // ...
    // ...
    // ...
  ],
  "nextPageToken": "CPii5aS87vfFTBAKGJvk36qpLiIWUW5SZk8xa1JPaXJVdXdIR05JUUpxZyoCVjMwADjUBkD___________8B",
  "fieldMask": "adGroupCriterion.keyword.text,adGroupCriterion.status"
}

Repeating the same query with a pageToken added with the value above fetches the next page of results:

POST /v0/customers/CUSTOMER_ID/searchAds360:search HTTP/1.1
Host: searchads360.googleapis.com
Content-Type: application/json
Authorization: Bearer ACCESS_TOKEN


{
"pageSize": 10000,
"query": "SELECT ad_group_criterion.keyword.text, ad_group_criterion.status FROM ad_group_criterion WHERE ad_group_criterion.type = 'KEYWORD' AND ad_group_criterion.status = 'ENABLED'",
"pageToken": "CPii5aS87vfFTBAKGJvk36qpLiIWUW5SZk8xa1JPaXJVdXdIR05JUUpxZyoCVjMwADjUBkD___________8B"
}

To use the SearchStream method, which returns all results in a single streamed response, simply change the service method in the URL to searchStream (pageSize and pageToken are not required by SearchStream):

POST /v0/customers/CUSTOMER_ID/searchAds360:searchStream HTTP/1.1
Host: searchads360.googleapis.com
Content-Type: application/json
Authorization: Bearer ACCESS_TOKEN

{
    "query": "SELECT ad_group_criterion.keyword.text, ad_group_criterion.status FROM ad_group_criterion WHERE ad_group_criterion.type = 'KEYWORD' AND ad_group_criterion.status = 'ENABLED'"
}