1.0.8 • Published 6 months ago

@ayasdev/amazon-ads-sdk v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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: 1. Fork the repository 2. Create your own package under your organization's name 3. 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: 1. Set up Amazon Advertising API access - Apply for API Access 2. Create an LWA application - Create LWA App Guide 3. Assign API access to users - Assign API Access 4. Generate authorization credentials - Create Authorization Grant

Installation

npm install @ayasdev/amazon-ads-sdk

or

yarn add @ayasdev/amazon-ads-sdk

Configuration

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=false

SDK 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
          └── api

Campaigns

  • sdk.sp.campaigns: Campaign management (CRUD operations)
  • sdk.sp.campaigns.optimization: Campaign optimization rules
  • sdk.sp.campaigns.budget: Budget management operations

Keywords

  • sdk.sp.keywords: Keyword management
  • sdk.sp.keywords.recommendations: Keyword recommendations
  • sdk.sp.keywords.negative: Negative keyword operations

Targeting

  • sdk.sp.targeting: Targeting operations
  • sdk.sp.targeting.negative.campaign: Campaign-level negative targeting
  • sdk.sp.targeting.negative: Ad group-level negative targeting
  • sdk.sp.targeting.product.promotions: Product promotion targeting

Other Operations

  • sdk.sp.adGroups: Ad group management
  • sdk.sp.productAds: Product ad operations
  • sdk.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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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.

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago