@ayasdev/amazon-ads-sdk
v1.0.8
Published
A comprehensive TypeScript/JavaScript SDK for Amazon Advertising API with full type support
Maintainers
Readme
Amazon Ads SDK
TypeScript/JavaScript SDK for Amazon Advertising API.
⚠️ Important Notice
This SDK is primarily developed for internal use in our company's applications. As such:
- The API structure may undergo significant changes without prior notice
- Breaking changes are likely to occur frequently
- Features may be added or removed based on our internal needs
Recommendation: If you want to use this SDK in your project, we strongly recommend:
- Fork the repository
- Create your own package under your organization's name
- Maintain your own version based on your specific requirements
This approach will give you full control over the SDK's development and protect you from unexpected breaking changes.
Features
- TypeScript support
- Environment variables configuration
- Sandbox mode
- Sponsored Products API support
- Campaign management
- Targeting
- Keywords
- Budget rules
Prerequisites
Before using this SDK, you need to:
- Set up Amazon Advertising API access - Apply for API Access
- Create an LWA application - Create LWA App Guide
- Assign API access to users - Assign API Access
- Generate authorization credentials - Create Authorization Grant
Installation
npm install @ayasdev/amazon-ads-sdkor
yarn add @ayasdev/amazon-ads-sdkConfiguration
Environment Variables
Store your credentials securely in a .env file:
AMAZON_CLIENT_ID=your-client-id
AMAZON_CLIENT_SECRET=your-client-secret
AMAZON_REFRESH_TOKEN=your-refresh-token
AMAZON_REGION=EU
SANDBOX_MODE=falseSDK Initialization
import { AmazonAdsSDK } from '@ayasdev/amazon-ads-sdk';
const sdk = new AmazonAdsSDK({
clientId: 'your-client-id',
clientSecret: 'your-client-secret',
refreshToken: 'your-refresh-token',
region: 'EU', // Supported regions: NA (North America), EU (Europe), FE (Far East)
sandbox: false // Set to true for sandbox mode
});API Structure
Sponsored Products (SP) Namespace
SDK structure for the Sponsored Products section of Amazon Advertising API:
sdk.sp
├── campaigns
│ ├── optimization
│ └── budget
├── adGroups
├── productAds
├── keywords
│ ├── recommendations
│ └── negative
└── targeting
├── product
│ └── promotions
└── negative
├── campaign
└── apiCampaigns
sdk.sp.campaigns: Campaign management (CRUD operations)sdk.sp.campaigns.optimization: Campaign optimization rulessdk.sp.campaigns.budget: Budget management operations
Keywords
sdk.sp.keywords: Keyword managementsdk.sp.keywords.recommendations: Keyword recommendationssdk.sp.keywords.negative: Negative keyword operations
Targeting
sdk.sp.targeting: Targeting operationssdk.sp.targeting.negative.campaign: Campaign-level negative targetingsdk.sp.targeting.negative: Ad group-level negative targetingsdk.sp.targeting.product.promotions: Product promotion targeting
Other Operations
sdk.sp.adGroups: Ad group managementsdk.sp.productAds: Product ad operationssdk.sp.productRecommendations: Product recommendations
Usage Examples
// Get campaigns
const campaigns = await sdk.sp.campaigns.list(profileId);
// Get ad groups
const adGroups = await sdk.sp.adGroups.list(profileId);
// Get targeting
const targeting = await sdk.sp.targeting.list(profileId);
// Get negative targeting
const negativeTargeting = await sdk.sp.targeting.negative.list(profileId);Error Handling
try {
const campaigns = await sdk.sp.campaigns.list(profileId);
} catch (error) {
if (error.response) {
// Amazon API error
console.error('API Error:', error.response.data);
} else {
// Network or other error
console.error('Error:', error.message);
}
}Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For support, please open an issue in the GitHub repository or contact the maintainers directly.
