Socket
Socket
Sign inDemoInstall

@scaleleap/selling-partner-api-sdk

Package Overview
Dependencies
3
Maintainers
2
Versions
92
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scaleleap/selling-partner-api-sdk

📦 A fully typed TypeScript and Node.js SDK library for Amazon Selling Partner API


Version published
Maintainers
2
Created

Changelog

Source

7.0.0 (2024-04-03)

Bug Fixes

  • deps: update dependency aws4-axios to v3.3.4 (#1018) (40f547d)
  • deps: update dependency axios to v1.6.8 (#1023) (ae0275e)
  • installs @scaleleap/semantic-release-config (dccfedb)
  • remove singing requests (#951) (4169903)
  • update @scaleleap/semantic-release-config (03d1fe4)

Features

BREAKING CHANGES

Adds support for:

  • Data Kiosk APi
  • Fulfillment Inbound API (v20240320)
  • Shipping API (v2)
  • Supply Sources API

Readme

Source

Selling Partner API for Node.js

NPM License GitHub Workflow Status Codecov Snyk Semantic Release FOSSA Status


  • A fully typed TypeScript and Node.js SDK package for Amazon Selling Partner API
  • Uses models from API model's repo to generate classes automatically
  • Picks up changes and releases daily when/if models have drifted
  • Based on Axios and uses aws4-axios interceptor to automatically sign the requests
  • Can optionally assume roles via STS, and refresh STS credentials on schedule

Download & Installation

npm i -s @scaleleap/selling-partner-api-sdk

Getting Started

Prerequisites

A few things to get started:

Authorizing Selling Partner API

Note that it is outside the responsibility of this package to handle the authorization process.

This package assumes you have already acquired the access and refresh tokens either by going through the OAuth flow or by using a self-authorized set of credentials.

Basic Usage

Using Existing AWS Credentials

This method is applicable if you want to assume the Selling Partner API role yourself, or you are using a static set of user credentials (not recommended).

import { SellersApiClient } from '@scaleleap/selling-partner-api-sdk'

const stsClient = new STSClient({
  // Static set of credentials that have the permission to assume the role above
  credentials: {
    accessKeyId: 'AKIAIOSFODNN7EXAMPLE',
    secretAccessKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY',
  },
})

const { Credentials } = await stsClient.send(
  new AssumeRoleCommand({
    // This is the role you have set in your Selling Partner API application
    RoleArn: 'arn:aws:iam::123456789012:role/your-SP-API-role-name',
    RoleSessionName: 'selling-partner-api-axios',
  }),
)

const client = new SellersApiClient({
  accessToken: 'Atza|...',

  // Or use `amazonMarketplaces.CA.sellingPartner.region.endpoint`
  // from `@scaleleap/amazon-marketplaces` package
  basePath: 'https://sellingpartnerapi-na.amazon.com',

  // Or use `amazonMarketplaces.CA.sellingPartner.region.awsRegion`
  // from `@scaleleap/amazon-marketplaces` package
  region: 'us-east-1',

  credentials: {
    accessKeyId: Credentials?.AccessKeyId || '',
    secretAccessKey: Credentials?.SecretAccessKey || '',
    sessionToken: Credentials?.SessionToken || '',
  }
})

const marketplaceParticipations = await client.getMarketplaceParticipations()
Letting @scaleleap/selling-partner-api-sdk to Assume the Role

This package uses aws4-axios under the hood, which has the capability to make the STS call and get the credentials for you, and refresh the temporary AWS credentials session.

import { SellersApiClient } from '@scaleleap/selling-partner-api-sdk'

const client = new SellersApiClient({
  accessToken: 'Atza|...',

  // Or use `amazonMarketplaces.CA.sellingPartner.region.endpoint`
  // from `@scaleleap/amazon-marketplaces` package
  basePath: 'https://sellingpartnerapi-na.amazon.com',

  // Or use `amazonMarketplaces.CA.sellingPartner.region.awsRegion`
  // from `@scaleleap/amazon-marketplaces` package
  region: 'us-east-1',

  // This is the role you have set in your Selling Partner API application
  roleArn: 'arn:aws:iam::123456789012:role/your-SP-API-role-name',

  // Static set of credentials that have the permission to assume the role above
  credentials: {
    accessKeyId: 'AKIAIOSFODNN7EXAMPLE',
    secretAccessKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY',
  },
})

const marketplaceParticipations = await client.getMarketplaceParticipations()

See the full list of exported classes and types: src/api-models/index.ts.

See @scaleleap/amazon-marketplaces docs for a database of constants about Amazon Marketplaces.

Documentation

Contributing

This repository uses Conventional Commit style commit messages.

Authors or Acknowledgments

License

This project is licensed under the MIT License.

FOSSA Status

Keywords

FAQs

Package last updated on 03 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc