npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@scaleleap/selling-partner-api-sdk

v8.3.0

Published

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

Downloads

13,342

Readme

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