Dostępny jest już nowy interfejs Search Ads 360 Reporting API. Dołącz do grupy dyskusyjnej Google searchads-api-announcements, aby na bieżąco otrzymywać informacje o nadchodzących ulepszeniach i wersjach.
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Ten przewodnik zawiera przykłady bezpośredniego wywoływania punktów końcowych REST bez użycia biblioteki klienta.
Wymagania wstępne
Wszystkie poniższe przykłady można łatwo skopiować i wkleić do powłoki bash za pomocą polecenia curl. Musisz mieć konto menedżera Search Ads 360, które zawiera co najmniej 1 konto klienta.
Zmienne środowiskowe
Wpisz poniżej dane logowania i identyfikatory konta, a potem skopiuj je i wklej do terminala, aby skonfigurować zmienne środowiskowe używane w kolejnych przykładach.
Poniższe przykłady działają w przypadku istniejących kampanii. Jeśli masz identyfikatory istniejącej kampanii, których chcesz użyć w tych przykładach, wpisz je poniżej.
CAMPAIGN_ID=CAMPAIGN_ID
Wyszukiwanie z podziałem na strony
Metoda search korzysta z paginacji z regulowanym parametrem pageSize określonym obok parametru query.
[null,null,["Ostatnia aktualizacja: 2025-08-29 UTC."],[[["\u003cp\u003eThis guide provides examples of directly calling Search Ads 360 REST endpoints using curl, bypassing the need for a client library.\u003c/p\u003e\n"],["\u003cp\u003eBefore running the examples, you'll need to set up environment variables for your API version, OAuth 2.0 access token, manager account ID, and client account ID.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code samples demonstrate both paginated search using the \u003ccode\u003esearch\u003c/code\u003e method with an adjustable \u003ccode\u003epageSize\u003c/code\u003e and streaming search using the \u003ccode\u003esearchStream\u003c/code\u003e method which returns all results at once.\u003c/p\u003e\n"],["\u003cp\u003eAll examples utilize the SA360 Query Language for data retrieval, focusing on campaign data like name, budget, status, and performance metrics.\u003c/p\u003e\n"]]],["This guide demonstrates direct REST endpoint calls using `curl` within a bash shell, targeting a Search Ads 360 client account accessible via a manager account. It outlines setting environment variables for API version, OAuth token, manager ID, and customer ID. The document provides examples for executing paginated searches using the `search` method with adjustable `pageSize` and the `searchStream` method to retrieve all data at once. Both methods use SA360 Query Language to specify the desired campaign data.\n"],null,["# Examples\n\nThis guide contains examples of calling the REST endpoints directly, without the\nuse of a client library.\n\nPrerequisites\n-------------\n\nAll the samples below are meant to be easily copy-and-pasteable into a\n[bash shell](https://www.gnu.org/software/bash/) using\n[curl](https://curl.se/) command. You will need a Search Ads 360 manager account containing at least one client account.\n| **Important:** In these examples, we assume that you are accessing a client account (`CUSTOMER_ID`) by a user that has administrative access to a manager account (`MANAGER_CUSTOMER_ID`) that directly manages the client account. If you are instead accessing an individual client account directly, omit the `login-customer-id` header or set it to the same value as `CUSTOMER_ID`.\n\n### Environment variables\n\nEnter account credentials and IDs below, and then copy-and-paste into your\nterminal to configure the environment variables used in the subsequent examples.\n**Note:** The [Authorization](/search-ads/reporting/api/reference/rest/auth) guide provides instructions for generating an OAuth 2.0 access token. \n\n API_VERSION=\"0\"\n OAUTH2_ACCESS_TOKEN=\"\u003cvar translate=\"no\"\u003eOAUTH_ACCESS_TOKEN\u003c/var\u003e\"\n MANAGER_CUSTOMER_ID=\"\u003cvar translate=\"no\"\u003eMANAGER_CUSTOMER_ID\u003c/var\u003e\"\n CUSTOMER_ID=\"\u003cvar translate=\"no\"\u003eCUSTOMER_ID\u003c/var\u003e\"\n\n#### Additional optional object IDs\n\nThe following examples work on pre-existing campaigns. If you\nhave IDs of an existing campaign to use with these examples, enter it below. \n\n CAMPAIGN_ID=\u003cvar translate=\"no\"\u003eCAMPAIGN_ID\u003c/var\u003e\n\n### Paginated search\n\nThe `search` method uses pagination, with an adjustable `pageSize` parameter\nspecified alongside the `query`. \n\n### cURL\n\n```console\n#!/bin/bash\n# [START curl_command]\ncurl -f --request POST \"https://searchads360.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/searchAds360:search\" \\\n--header \"Content-Type: application/json\" \\\n--header \"login-customer-id: ${MANAGER_CUSTOMER_ID}\" \\\n--header \"Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}\" \\\n--data '{\n\"pageSize\": 10,\n\"query\": \"\n SELECT campaign.name,\n campaign_budget.amount_micros,\n campaign.status,\n campaign.advertising_channel_type,\n metrics.clicks,\n metrics.impressions,\n metrics.ctr,\n metrics.average_cpc,\n metrics.cost_micros,\n campaign.bidding_strategy_type\n FROM campaign\n WHERE segments.date DURING LAST_7_DAYS\n AND campaign.status != 'REMOVED'\n\"\n}'\n# [END curl_command]\n```\n\n### SA360 Query Language\n\n```sql\n SELECT campaign.name,\n campaign_budget.amount_micros,\n campaign.status,\n campaign.advertising_channel_type,\n metrics.clicks,\n metrics.impressions,\n metrics.ctr,\n metrics.average_cpc,\n metrics.cost_micros,\n campaign.bidding_strategy_type\n FROM campaign\n WHERE segments.date DURING LAST_7_DAYS\n AND campaign.status != 'REMOVED'\n```\n\n### Streaming\n\nThe `searchStream` method streams all results in a single response, and thus the\n`pageSize` field is not supported. \n\n### cURL\n\n```console\n#!/bin/bash\n# [START curl_command]\ncurl -f --request POST \"https://searchads360.googleapis.com/v${API_VERSION}/customers/${CUSTOMER_ID}/searchAds360:searchStream\" \\\n--header \"Content-Type: application/json\" \\\n--header \"login-customer-id: ${MANAGER_CUSTOMER_ID}\" \\\n--header \"Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}\" \\\n--data '{\n\"query\": \"\n SELECT campaign.name,\n campaign_budget.amount_micros,\n campaign.status,\n campaign.advertising_channel_type,\n metrics.clicks,\n metrics.impressions,\n metrics.ctr,\n metrics.average_cpc,\n metrics.cost_micros,\n campaign.bidding_strategy_type\n FROM campaign\n WHERE segments.date DURING LAST_7_DAYS\n AND campaign.status != 'REMOVED'\n\"\n}'\n# [END curl_command]\n```\n\n### SA360 Query Language\n\n```sql\n SELECT campaign.name,\n campaign_budget.amount_micros,\n campaign.status,\n campaign.advertising_channel_type,\n metrics.clicks,\n metrics.impressions,\n metrics.ctr,\n metrics.average_cpc,\n metrics.cost_micros,\n campaign.bidding_strategy_type\n FROM campaign\n WHERE segments.date DURING LAST_7_DAYS\n AND campaign.status != 'REMOVED'\n```"]]