This library provides an unofficial Node.js client for interacting with the Google Ads API, currently supporting API version 23.0.0. It aims to offer a simplified and easy-to-use interface, leveraging REST and Protocol Buffers internally for underlying communication. The library maintains a strong focus on developer experience by shipping comprehensive TypeScript definitions for all resources, enums, errors, and services, ensuring strong type-checking and autocompletion. While unofficial, it typically tracks Google Ads API releases closely, with major library versions often aligning with new Google Ads API versions. Key differentiators include its full API functionality coverage, support for both declarative `report` and raw GAQL `query` methods, and the provision of hooks for various service methods. It's a robust alternative for Node.js developers requiring programmatic access to Google Ads.
npm install google-ads-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Google Ads API client, retrieve a list of enabled campaigns with various metrics, and list all customer accounts accessible by the provided refresh token. It highlights the use of environmental variables for secure credential management.
Migrate code to use `report` or `query` methods with Google Ads Query Language (GAQL) for retrieving resources. For example, instead of `customer.getCampaign(campaignId)`, use `await customer.report({ entity: 'campaign', constraints: { 'campaign.id': campaignId } })`.Double-check all credentials against your Google Ads Manager Account. Ensure the developer token is approved and has the correct access level. Verify the `refresh_token` has access to the specified `customer_id` and that the `login_customer_id` is correct if managing multiple accounts.
Implement robust error handling with exponential backoff and retry mechanisms for API calls. Review Google Ads API quota limits documentation and optimize your API request patterns.
Stay updated with the library's releases and Google Ads API release notes. Test thoroughly when upgrading to new Google Ads API versions or when new features are critical.
Always verify that the `customer_id` provided corresponds to an actual customer account accessible by the `refresh_token`. If managing multiple accounts, ensure `login_customer_id` is set correctly to the manager account through which you access the target customer.
Implement an exponential backoff strategy for retrying failed API calls and review the Google Ads API quotas to ensure your usage aligns with limits. Consider batching operations where possible.
Log into your Google Ads Manager Account, navigate to API Center, and verify the Developer Token. Ensure it's active and has the required access (e.g., Test Account, Basic, Standard access).
Verify that the `refresh_token` was generated for a Google account that has permission to access the `customer_id`. If using a manager account, ensure `login_customer_id` is set to the manager account ID.
Refactor your code to use the `customer.report()` method with appropriate GAQL. For example, to get a campaign by ID, use `await customer.report({ entity: 'campaign', constraints: { 'campaign.id': '<YOUR_CAMPAIGN_ID>' } })`.No dependency data recorded yet.