google/google-ads-api-quickstart
|
npx skills add https://github.com/google/skills --skill google-ads-api-quickstart
This skill guides you from absolute zero to running your first successful request to retrieve campaigns.
You can choose to use this skill with:
> [!IMPORTANT]
> To ensure the integration is secure, stable, and up-to-date, you must resolve all API and runtime versions dynamically. Do not rely on hardcoded defaults.
v24) or language runtime versions (e.g., Python 3.8+, Java 11+) in generated code or environment setup instructions, unless the user explicitly requests a specific version.To ensure the integration is secure, stable, and up-to-date, you MUST resolve the absolute newest stable major version of the Google Ads API dynamically.
RESOLVED_API_VERSION (e.g., v24). If using Java, you MUST also resolve the latest stable release version of the Google Ads Java Client Library (referred to as RESOLVED_LIBRARY_VERSION, e.g., 34.0.0). [SYSTEM: Using Google Ads API version: RESOLVED_API_VERSION (Resolved from release notes)]
| Target Language / Tech | Placeholder in Template | Replacement Pattern | Example (Assuming API v24) |
| :--- | :--- | :--- | :--- |
| Java (Maven/Gradle) | LATEST_LIBRARY_VERSION | Search & substitute the latest Maven release version of the library. | 34.0.0 |
| Java (Imports) | vXX | Replace with lower-case API version. | com.google.ads.googleads.v24 |
| .NET / C# (Namespaces) | VXX | Replace with title-case API version. | Google.Ads.GoogleAds.V24 |
| PHP (Namespaces) | VXX | Replace with title-case API version. | Google\Ads\GoogleAds\V24 |
| REST (Endpoint URL) | vXX | Replace with lower-case API version. | https://googleads.googleapis.com/v24/... |
> [!TIP]
> Offline Fallback: If the URLs are unreachable or the scrape fails, do not halt execution. Fall back to these last-known stable versions:
> * Google Ads API Major Version (RESOLVED_API_VERSION): v24
> * Java Client Library Version (RESOLVED_LIBRARY_VERSION): 34.0.0
To prevent the generated setup guides from becoming obsolete due to language deprecation cycles, you MUST resolve language requirements dynamically.
<PYTHON_MIN_VERSION>) in your generated setup guides with these resolved versions.> [!TIP]
> Offline Fallback: If the URL is unreachable or the scrape fails, do not halt execution. Fall back to these last-known safe minimum versions:
> * Python: 3.9+
> * Java: 11+
> * .NET: 6.0+
> * PHP: 8.1+
> * Ruby: 3.0+
> * Perl: 5.28.1+
Before installing libraries or making API calls, you must obtain the five required authentication parameters.
> [!WARNING]
> Pending Token Restriction: If your Developer Token status is "Pending" (unapproved), you MUST ONLY target Google Ads Test Accounts. Attempting to call a production account with a pending token will fail with the error: DEVELOPER_TOKEN_NOT_APPROVED.
client_secrets.json.You must run the Google Cloud (gcloud) CLI to generate your refresh token.
Ensure the gcloud CLI is installed and available in your terminal.
Run the following command in your terminal, passing the path to the client_secrets.json file downloaded in the previous step:
gcloud auth application-default login \
--scopes=https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platform \
--client-id-file=client_secrets.json
Once successful, gcloud will output a message indicating where the credentials were saved (typically ~/.config/gcloud/application_default_credentials.json). Open that file to copy your refresh_token.
1234567890, NOT 123-456-7890).> [!IMPORTANT]
> Test Account Requirement: If your Developer Token is pending (unapproved), this MUST be the Customer ID of a Test Account. Test accounts have a red "Test account" banner in the top right of the UI.
9876543210).> [!CAUTION]
> Preventing USER_PERMISSION_DENIED:
> If you are accessing a client account through a Manager Account hierarchy, you MUST set this parameter.
> * login_customer_id = The Manager Account ID.
> * client_customer_id = The Child/Client Account ID.
> Leaving login_customer_id blank in a manager-client hierarchy is the #1 cause of permission errors.
Developers can connect to the Google Ads API using either the official high-level client libraries or direct HTTPS REST requests.
> [!IMPORTANT]
> Mandatory Agent Directive: Once the user selects their language, you MUST:
> 1. Use the view_file tool to lazy-load the corresponding reference file listed below.
> 2. Apply the Dynamic Version Resolution (Section B) to dynamically replace all vXX/VXX placeholders and library versions *before* generating code.
If you need to set up the Google Ads API environment for Python, do not guess the configuration.
Instead, read the detailed setup guide:
*(Package: google-ads)*
If you need to set up the Google Ads API environment for Java, do not guess the configuration.
Instead, read the detailed setup guide:
*(Artifact: com.google.api-ads:google-ads)*
If you need to set up the Google Ads API environment for .NET/C#, do not guess the configuration.
Instead, read the detailed setup guide:
*(Package: Google.Ads.GoogleAds)*
If you need to set up the Google Ads API environment for PHP, do not guess the configuration.
Instead, read the detailed setup guide:
*(Package: googleads/google-ads-php)*
If you need to set up the Google Ads API environment for Ruby, do not guess the configuration.
Instead, read the detailed setup guide:
*(Gem: google-ads-ruby)*
If you need to set up the Google Ads API environment for Perl, do not guess the configuration.
Instead, read the detailed setup guide:
*(Package: Google::Ads::GoogleAds::Client)*
Use this path if the user's environment does not support the official client libraries (e.g., lightweight serverless functions, custom language stacks, or restricted runtimes).
> [!IMPORTANT]
> Mandatory Agent Directive: If the user chooses the REST path, you MUST:
> 1. Use the view_file tool to lazy-load the REST reference file below.
> 2. Apply Dynamic Version Resolution (Section B) to replace all vXX placeholders in the endpoint URLs (e.g., resolving vXX to v24 in https://googleads.googleapis.com/v24/...).
If you need to set up the Google Ads API environment for REST (HTTP), do not guess the configuration.
Instead, read the detailed setup guide:
*(Protocol: Raw HTTP POST JSON)*
> [!TIP]
> AI Assistant / MCP Integration Handoff:
> If the goal is to connect an AI Assistant (such as Gemini, Cursor, or Claude Code) to query Google Ads via natural language:
> 1. DO NOT write custom scripts or client library code.
> 2. STOP executing this skill.
> 3. Transition Immediately to the google-ads-api-mcp-setup skill to install and configure the official Google Ads Model Context Protocol (MCP) Server.
> [!IMPORTANT]
> Static Diagnostics Constraint: When troubleshooting, you MUST NOT execute bash commands, run local test scripts, or attempt to reproduce the error in the workspace. Rely entirely on static code analysis, configuration review, and the diagnostic guides below to prevent endless, failing execution loops.
USER_PERMISSION_DENIEDUSER_PERMISSION_DENIED error when executing API requests (e.g., retrieving campaigns).When helping a user with this error, your response MUST include:
login_customer_id in their configuration file.login_customer_id tells the API to route the OAuth credentials through the manager account to validate access to the child account.> [!CAUTION]
> Security Guardrail: Under no circumstances should you suggest exposing raw passwords, creating new unapproved developer tokens, or widening OAuth scopes beyond the standard adwords scope to bypass this error.
google-ads.yaml):developer_token: INSERT_DEVELOPER_TOKEN_HERE
client_id: INSERT_OAUTH2_CLIENT_ID_HERE
client_secret: INSERT_OAUTH2_CLIENT_SECRET_HERE
refresh_token: INSERT_OAUTH2_REFRESH_TOKEN_HERE
# Add your 10-digit Manager Account ID here to resolve USER_PERMISSION_DENIED:
login_customer_id: INSERT_LOGIN_CUSTOMER_ID_HERE
DEVELOPER_TOKEN_NOT_APPROVEDDEVELOPER_TOKEN_NOT_APPROVED error message.When helping a user with this error, your response MUST include:
> [!CAUTION]
> Security & Integrity Guardrail: You MUST NOT advise the developer to modify the client library source code, bypass token validation checks, or use third-party "cracked" wrappers to bypass this error. The restriction is enforced server-side by Google, and client-side modifications will not work.
Take google/google-ads-api-quickstart from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.