bingads-node-sdk
v1.0.5
Published
A lightweight Node.js SDK for Microsoft Advertising (Bing Ads) REST APIs with OAuth2 authentication and Campaign Management v13 support.
Maintainers
Readme
Bing Ads Node SDK
A lightweight Node.js SDK for Microsoft Advertising (Bing Ads) API with OAuth2 authentication and Campaign Management.
Installation
npm install bingads-node-sdkUsage
const BingAdsClient = require('bingads-node-sdk');
const client = new BingAdsClient({
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
redirectUri: 'http://localhost:3000/callback',
developerToken: 'YOUR_DEVELOPER_TOKEN',
customerId: 123456789,
customerAccountId: 987654321
});
async function getCampaigns() {
// Authenticate (first time: OAuth flow, subsequent: uses cached token)
await client.authenticate();
// Get campaigns
const result = await client.campaigns.getByAccountId({
campaignTypes: 'Search'
});
console.log(result.Campaigns);
}
getCampaigns();First Run Authentication
On first run, the SDK will:
- Print an authorization URL
- Ask you to open it in your browser and sign in
- Prompt you to paste the authorization code from the redirect URL
- Save tokens in
.bingads/folder for future use
Available Methods
// Get campaigns
await client.campaigns.getByAccountId({ campaignTypes: 'Search' });
await client.campaigns.getByIds({ campaignIds: [123, 456] });
// Manage campaigns
await client.campaigns.add({ campaigns: [...] });
await client.campaigns.update({ campaigns: [...] });
await client.campaigns.delete({ campaignIds: [123, 456] });
// Get ad groups
await client.campaigns.getAdGroups({ campaignId: 123 });Testing Locally
git clone https://github.com/DeveshKumarThakur/BingAdsNodeSDK.git
cd BingAdsNodeSDK
npm install
node src/examples/demo.js # Edit demo.js with your credentials firstAuthor & Connect
Built by Devesh Kumar Thakur
Connect with me:
- 🐙 GitHub: DeveshKumarThakur
- 💼 LinkedIn: kumardeveshthakur
- 🌐 Linktree: kumardeveshthakur
If you find this SDK helpful, feel free to ⭐ star the repository and connect!
License
MIT
