{"id":20037563,"url":"https://github.com/mrdulin/nodejs-google-adwords","last_synced_at":"2025-05-05T06:31:01.851Z","repository":{"id":34837952,"uuid":"141218023","full_name":"mrdulin/nodejs-google-adwords","owner":"mrdulin","description":"Google Ads API Client Library for Node.js (SOAP + WSDL)","archived":false,"fork":false,"pushed_at":"2023-06-01T05:55:46.000Z","size":3122,"stargazers_count":15,"open_issues_count":0,"forks_count":6,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-05T14:07:30.165Z","etag":null,"topics":["google","google-ads","google-ads-api","google-adwords","node-soap","nodejs","nodejs-google-adwords","soap","soap-web-services","soap-wsdl","typescript","wsdl"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrdulin.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-17T02:07:47.000Z","updated_at":"2023-10-20T11:22:26.000Z","dependencies_parsed_at":"2023-01-15T09:30:35.841Z","dependency_job_id":null,"html_url":"https://github.com/mrdulin/nodejs-google-adwords","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-google-adwords","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-google-adwords/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-google-adwords/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrdulin%2Fnodejs-google-adwords/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrdulin","download_url":"https://codeload.github.com/mrdulin/nodejs-google-adwords/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224428465,"owners_count":17309515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google","google-ads","google-ads-api","google-adwords","node-soap","nodejs","nodejs-google-adwords","soap","soap-web-services","soap-wsdl","typescript","wsdl"],"created_at":"2024-11-13T10:20:06.245Z","updated_at":"2024-11-13T10:20:07.325Z","avatar_url":"https://github.com/mrdulin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nodejs google adwords\n\n[![NPM Downloads][downloads-image]][downloads-url]\n![LICENSE][license-image]\n[![Build Status](https://travis-ci.org/mrdulin/nodejs-google-adwords.svg?branch=master)](https://travis-ci.org/mrdulin/nodejs-google-adwords)\n[![Coverage Status](https://coveralls.io/repos/github/mrdulin/nodejs-google-adwords/badge.svg?branch=master)](https://coveralls.io/github/mrdulin/nodejs-google-adwords?branch=master)\n[![StackShare](http://img.shields.io/badge/tech-stack-0690fa.svg?style=flat)](https://stackshare.io/mrdulin/nodejs-google-adwords)\n\nGoogle Ads API Client Library for Node.js. This library is developed for Google Adwords SOAP + WSDL API (v201809).\n\n## OAuth\n\nReplace your GCP OAuth 2.0 client ID and open this link in browser,\n\n```bash\nhttps://accounts.google.com/o/oauth2/auth?client_id={Your Client ID}\u0026response_type=code\u0026scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fadwords\u0026redirect_uri=urn:ietf:wg:oauth:2.0:oob\u0026access_type=offline\u0026approval_prompt=auto\n```\n\nThe OAuth2.0 Client type should be `other`, not web application\n\n![](https://raw.githubusercontent.com/mrdulin/pic-bucket-01/master/WX20190830-111739.png)\n\nIf you use client id which client type is `web application`, you will get below error:\n\n![](https://raw.githubusercontent.com/mrdulin/pic-bucket-01/master/WX20190830-112511.png)\n\nAfter finish the oauth workflow, you will get authorization code, for example: `4/0wA_JBMyfVH1ZEqZlAr0sOn_XmdzUrBgCjrpi9fVs9TudrjZUDzuUmU`\n\nUsing authorization code exchange credentials:\n\n```bash\ncurl \\\n  -d code=4/MgGqR_qEUkzq95LlP_Am8clUbX8t733PvtoMuZ_xsmAA8NHdjK07xXo \\\n  -d client_id=\u003cclient id\u003e \\\n  -d client_secret=\u003cclient secret\u003e \\\n  -d redirect_uri=urn:ietf:wg:oauth:2.0:oob \\\n  -d grant_type=authorization_code https://accounts.google.com/o/oauth2/token\n```\n\nCredentials response:\n\n```bash\n{\n  \"access_token\": \"\u003cAccess token\u003e\",\n  \"expires_in\": 3600,\n  \"refresh_token\": \"\u003cRefresh token\u003e\",\n  \"scope\": \"https://www.googleapis.com/auth/adwords\",\n  \"token_type\": \"Bearer\"\n}\n```\n\nYou can revoke your access token from: https://myaccount.google.com/u/0/permissions\n\nAbove workflow is only for server-side local development without a front-end(client-side), after you make a front-end application, then you can create a OAuth2.0 Client on GCP with `web application` type and set up your `Authorized JavaScript origins` and `Authorized redirect URIs` like below:\n\n![](https://raw.githubusercontent.com/mrdulin/pic-bucket-01/master/WX20190830-113014.png)\n\nThen, when user perform the oauth workflow, you can confirm the oauth workflow on server-side, and store the `refresh_token`, `access_token` and other informations in your database. When user click `create campaign` button on your front-end application, it will send a HTTP request to your server-side, then, you can get the user's `access_token` from database, can call google adwords api using this `access_token`.\n\n## Environment variables\n\n```txt\nADWORDS_CLIENT_ID=\u003cGCP OAuth 2.0 client ID\u003e\nADWORDS_SECRET=\u003cGCP OAuth 2.0 client secret\u003e\nADWORDS_DEVELOPER_TOKEN=\u003cGoogle Adwords Developer Token\u003e\nADWORDS_CLIENT_CUSTOMER_ID=153-935-9847\nADWORDS_USER_AGENT=Google Ads API Client Library for Node.js\nADWORDS_REFRESH_TOKEN=\u003cOAuth Refresh Token\u003e\n```\n\nPut above environment variables into `.env` file for local development.\n\n## Usage\n\nInitialize `AdwordsService` with above environment variables\n\n```ts\nconst adwordsService = new AdWordsService({\n  clientCustomerId: credentials.ADWORDS_CLIENT_CUSTOMER_ID,\n  developerToken: credentials.ADWORDS_DEVELOPER_TOKEN,\n  userAgent: credentials.ADWORDS_USER_AGENT,\n  clientId: credentials.ADWORDS_CLIENT_ID,\n  clientSecret: credentials.ADWORDS_SECRET,\n  credentials: {\n    refresh_token: credentials.ADWORDS_REFRESH_TOKEN,\n  },\n});\n```\n\nGet budgets by page:\n\n```ts\nasync function getByPage() {\n  const budgetService = adwordsService.getService('BudgetService');\n  const paging: IPaging = {\n    startIndex: 0,\n    numberResults: 2,\n  };\n  return await budgetService.getByPage(paging);\n}\n```\n\nCreate a budget:\n\n```ts\nasync function createBudget() {\n  const budgetService = adwordsService.getService('BudgetService');\n\n  const budget: IBudget = {\n    name: faker.lorem.word(),\n    amount: {\n      microAmount: BudgetService.UNIT,\n    },\n    deliveryMethod: Budget.BudgetDeliveryMethod.STANDARD,\n    isExplicitlyShared: false,\n    status: Budget.BudgetStatus.ENABLED,\n  };\n\n  return await budgetService.add(budget);\n}\n```\n\nGet campaigns by page:\n\n```ts\nasync function getCampaignsByPages() {\n  const paging: IPaging = {\n    startIndex: 0,\n    numberResults: 1,\n  };\n  return await campaignService.getByPage(paging);\n}\n```\n\nSame usage for other Google Adwords resources\n\n## TODO\n\n- [ ] \u003chttps://developers.google.com/adwords/api/docs/guides/batch-jobs\u003e\n- [ ] \u003chttp://adwordsapi.blogspot.in/2011/03/concurrency-management-in-adwords-api.html\u003e\n- [ ] Add model layer and object schema validation\n\n## References\n\n- \u003chttps://developers.google.com/adwords/api/docs/reference/release-notes/v201809?refresh=1\u003e\n- \u003chttps://github.com/googleads/googleads-python-lib/wiki\u003e\n- \u003chttps://developers.google.com/adwords/api/docs/guides/authentication\u003e\n- \u003chttps://developers.google.com/adwords/api/docs/guides/objects-methods\u003e\n- \u003chttps://developers.google.com/adwords/api/docs/samples/php/basic-operations#add-expanded-text-ads-to-an-ad-group\u003e\n- \u003chttps://developers.google.com/adwords/api/docs/guides/bestpractices\u003e\n- \u003chttps://developers.google.com/adwords/api/docs/guides/authentication#optimizing_oauth2_requests\u003e\n- \u003chttps://developers.google.com/adwords/api/docs/appendix/geotargeting#dma\u003e\n- \u003chttps://developers.google.com/adwords/api/docs/guides/reporting\u003e\n\n[downloads-image]: https://img.shields.io/npm/dt/nodejs-google-adwords.svg\n[downloads-url]: https://npmjs.org/package/nodejs-google-adwords\n[license-image]: https://img.shields.io/npm/l/nodejs-google-adwords.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdulin%2Fnodejs-google-adwords","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrdulin%2Fnodejs-google-adwords","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrdulin%2Fnodejs-google-adwords/lists"}