Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@scaleleap/selling-partner-api-sdk

ScaleLeap9.3kMIT8.3.0TypeScript support: included

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

amazon mws, amazon selling partner, amazon sp api, nodejs, selling partner api, sp-api, typescript

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

changelog

Changelog

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

8.3.0 (2024-10-15)

Features

  • get preparation details for a list of MSKUs (#1134) (b91c11d)

8.2.0 (2024-10-01)

Features

  • adds application integrations api client (#1125) (51758f9)

8.1.0 (2024-09-27)

Features

8.0.0 (2024-09-13)

Bug Fixes

Features

BREAKING CHANGES


Updated the IsBuyerRequestedCancel, IsGift and NumberOfItems object types from boolean/integer to string.

Co-authored-by: nguyentoanit 19872073+nguyentoanit@users.noreply.github.com

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

    • Removes authorization API client. Refer to the SP-API Deprecations table for more information.

Adds support for:

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

6.13.8 (2024-01-25)

Bug Fixes

  • deps: update dependency axios to v1.6.7 (ca93d20)

6.13.7 (2024-01-25)

Bug Fixes

  • deps: update dependency axios to v1.6.6 (cf37511)

6.13.6 (2024-01-06)

Bug Fixes

  • deps: update dependency axios to v1.6.5 (792511c)

6.13.5 (2024-01-04)

Bug Fixes

  • deps: update dependency axios to v1.6.4 (abeb9ba)

6.13.4 (2023-12-27)

Bug Fixes

  • deps: update dependency axios to v1.6.3 (9a60c08)

6.13.3 (2023-11-15)

Bug Fixes

  • deps: update dependency axios to v1.6.2 (0418cd0)

6.13.2 (2023-11-08)

Bug Fixes

  • deps: update dependency axios to v1.6.1 (18bc3aa)

6.13.1 (2023-10-27)

Bug Fixes

  • deps: update dependency axios to v1.6.0 (06332b2)

6.13.0 (2023-10-16)

Features

6.12.23 (2023-09-26)

Bug Fixes

  • deps: update dependency axios to v1.5.1 (d9a3ff5)

6.12.22 (2023-09-22)

Bug Fixes

  • deps: update dependency http-status-codes to v2.3.0 (90d1c36)

6.12.21 (2023-08-28)

Bug Fixes

  • deps: update dependency axios to v1.5.0 (a8f267b)

6.12.20 (2023-08-17)

Bug Fixes

  • deps: update dependency aws4-axios to v3.3.0 (62db4b4)

6.12.19 (2023-06-15)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.24 (1e16bbb)

6.12.18 (2023-06-14)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.23 (9f46d4f)

6.12.17 (2023-06-13)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.22 (ed2e3ab)

6.12.16 (2023-06-12)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.21 (b27ff89)

6.12.15 (2023-06-09)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.20 (ac39c2b)

6.12.14 (2023-06-08)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.19 (e87a6fb)

6.12.13 (2023-06-08)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.18 (fff0ffe)

6.12.12 (2023-06-07)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.17 (d110311)

6.12.11 (2023-06-06)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.16 (f05b918)

6.12.10 (2023-06-05)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.15 (ba75861)

6.12.9 (2023-06-02)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.12 (9e58af2)

6.12.8 (2023-06-02)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.11 (3371996)

6.12.7 (2023-05-31)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.9 (41d66ed)

6.12.6 (2023-05-30)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.7 (b88a370)
  • deps: update dependency aws4-axios to v3.2.8 (b898e9a)

6.12.5 (2023-05-29)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.6 (db2eabb)

6.12.4 (2023-05-26)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.4 (f9a50ab)

6.12.3 (2023-05-25)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.2 (da0f3fe)

6.12.2 (2023-05-22)

Bug Fixes

  • deps: update dependency aws4-axios to v3.2.1 (b1e6781)

6.12.1 (2023-05-19)

Bug Fixes

  • deps: update dependency aws4-axios to v3.1.14 (fc35b89)

6.12.0 (2023-05-18)

Bug Fixes

  • deps: update dependency aws4-axios to v3.1.10 (c4f35a1)
  • deps: update dependency aws4-axios to v3.1.11 (9873d85)
  • deps: update dependency aws4-axios to v3.1.12 (8019875)
  • deps: update dependency aws4-axios to v3.1.13 (7d6ba0e)
  • deps: update dependency aws4-axios to v3.1.2 (a8c868e)
  • deps: update dependency aws4-axios to v3.1.4 (c29bf4c)
  • deps: update dependency aws4-axios to v3.1.6 (72921f8)
  • deps: update dependency aws4-axios to v3.1.7 (dc19176)

Features

  • add product pricing api client v20220501 (#784) (e4e7ff5)

6.11.1 (2023-05-08)

Bug Fixes

6.11.0 (2022-12-30)

Features

  • add events information in finances api model (#668) (0325cbd)

6.10.3 (2022-12-07)

Bug Fixes

  • missing data in catalog items api v20220401 (#650) (38abc00)

6.10.2 (2022-12-06)

Bug Fixes

6.10.1 (2022-11-21)

Reverts

  • Revert "chore(deps): update dependency ts-morph to v17 (#637)" (#639) (692b81c), closes #637 #639

6.10.0 (2022-09-29)

Features

  • add vendor shipping and customer invoice api (#568) (bd284da)

6.9.0 (2022-09-07)

Features

  • update catalog item api model v20220401 (#548) (2f34861)

6.8.0 (2022-08-22)

Features

  • add bulk scheduled packages in easy ship model (#527) (0d79fd2)

6.7.0 (2022-08-12)

Features

6.6.0 (2022-08-10)

Features

  • Improvements to the Orders API in support of Easy Ship shipments (#518) (0bf157c)

6.5.0 (2022-07-22)

Features

  • sends a message providing the buyer an invoice (#508) (51f67b6)

6.4.0 (2022-06-13)

Features

6.3.1 (2022-05-21)

Bug Fixes

  • item dimension type in Catalog Item V20220401 (#460) (cecdc3c)

6.3.0 (2022-05-19)

Features

6.2.4 (2022-05-18)

Bug Fixes

6.2.3 (2022-04-27)

Bug Fixes

  • deps: update dependency axios to v0.27.2 (ae635ca)

6.2.2 (2022-04-27)

Bug Fixes

  • deps: update dependency axios to v0.27.1 (fbe65e2)

6.2.1 (2022-04-27)

Bug Fixes

  • deps: update dependency axios to v0.27.0 (#433) (4461da1)

6.2.0 (2022-04-14)

Features

  • add vendor direct fulfillment and easy ship model (#424) (0069b77)

6.1.0 (2022-03-24)

Features

  • Add buyerRequestedCancel parameter to Orders API (#411) (6174ad6)

6.0.1 (2022-03-10)

Bug Fixes

  • deps: update dependency axios to v0.26.1 (6eae899)

6.0.0 (2022-03-09)

Features

BREAKING CHANGES

5.5.4 (2022-02-14)

Bug Fixes

  • deps: update dependency axios to v0.26.0 (5e4ce81)

5.5.3 (2022-02-04)

Bug Fixes

  • deps: update dependency aws4-axios to v2.4.9 (2042d02)

5.5.2 (2022-01-31)

Bug Fixes

  • deps: update dependency axios to v0.25.0 (#360) (33a0e4a)

5.5.1 (2021-12-27)

Bug Fixes

  • deps: update dependency http-status-codes to v2.2.0 (be66cbd)

5.5.0 (2021-12-13)

Features

5.4.0 (2021-11-23)

Features

5.3.1 (2021-11-22)

Bug Fixes

  • deps: update dependency aws4-axios to v2.4.6 (b3653a4)

5.3.0 (2021-11-16)

Features

  • add the PRODUCT_TYPE_DEFINITION_CHANGE notification type (#309) (2aa8d43)

5.2.0 (2021-11-08)

Features

  • add Kilograms and Pounds to weight unit (#299) (7bad0cf)

5.1.2 (2021-10-28)

Bug Fixes

  • deps: update dependency axios to v0.24.0 (#259) (40b6773)

5.1.1 (2021-10-27)

Bug Fixes

5.1.0 (2021-09-17)

Features

5.0.2 (2021-09-06)

Bug Fixes

  • deps: update dependency axios to v0.21.4 (af77da3)

5.0.1 (2021-09-06)

Bug Fixes

  • deps: update dependency axios to v0.21.3 (330308c)

5.0.0 (2021-08-25)

Bug Fixes

  • update pricing model for product pricing fields (8f29677)

BREAKING CHANGES

    • change availableDate type from number to string.
  • change QuantityDiscountType value from QuantityDiscount to QUANTITY_DISCOUNT.
  • remove VendorDirectFulfillmentShippingApiModelPackage export.
  • add ProductPricingApiModelPrimeInformationType.

4.1.3 (2021-08-24)

Bug Fixes

  • remove unused objects and update error type when get small and light fee preview (#213) (7a392f9)

4.1.2 (2021-08-11)

Bug Fixes

  • update generator to add missing methods when generate api clients (#203) (a20d48f)

4.1.1 (2021-08-09)

Bug Fixes

  • deps: update dependency aws4-axios to v2.4.3 (f6e0b0f)

4.1.0 (2021-08-03)

Features

4.0.0 (2021-07-27)

Code Refactoring

  • update granularity type in fba inventory api model's response (#183) (ecc0006)

BREAKING CHANGES

  • remove FbaInventoryApiModelGranularityGranularityTypeEnum enum export

3.8.0 (2021-07-09)

Features

  • return marketplace info and seller display name in order api (48cb19b)

3.7.0 (2021-07-08)

Features

  • add marketplace tax info and seller display name in shipment invoice (f4d8f13)

3.6.0 (2021-06-24)

Features

3.5.2 (2021-06-07)

Bug Fixes

3.5.1 (2021-06-03)

Bug Fixes

  • error code and message are no longer undefined (#134) (55b64b5)

3.5.0 (2021-06-03)

Features

  • add shipment invoicing, product type definitions and listings items api model (623872e)

Changelog

      All notable changes to this project will be documented in this file.
      See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

3.4.3 (2021-05-26)

Bug Fixes

  • deps: update dependency aws4-axios to v2.3.4 (61772f3)

3.4.2 (2021-05-20)

Bug Fixes

  • export all enums from root (19eb88c)

3.4.1 (2021-05-19)

Bug Fixes

  • change rate limit value as a number (c994ef4)

3.4.0 (2021-05-19)

Features

  • attempt to get rate limit value (234d12c)

3.3.0 (2021-05-19)

Features

  • return a list of error responses in vendor direct fulfillment orders api (493598b)

3.2.0 (2021-05-13)

Features

  • feat: update usage plan rates and rate tables in orders, product fees, product pricing (1f9d563)

3.1.0 (2021-05-05)

Features

3.0.0 (2021-04-27)

Code Refactoring

  • re-generate api client name using model directory name to prevent duplication (05e5502), closes #79

Reverts

BREAKING CHANGES

*

2.0.0 (2021-04-19)

Features

BREAKING CHANGES

    • re-generate api models
  • add token api client

1.0.0 (2021-03-25)

Bug Fixes

  • api configuration parameters's properties (dc2da96)
  • export combine schemas (374f532)
  • remove decoder from src folder (10f3b46)
  • remove helpers exporting (96d5c36)
  • remove unnecessary and private stuff exporting (4362ddc)
  • use generator v4.1.3 to fix build error (c324f6a)
  • use join method on set collection of api model code (2d063d6)
  • using generator v5.0.1 with type mapping to resolve build issue (a8c3463)

Features

  • add isSandbox option (644159c)
  • allow user set roleArn (7159ec7)
  • automate client version number dumps (e21d3d6)
  • check new commits before re-generate models (GHORG-38) (03c4ecb)
  • implement decoder and scripts to generate api model code commands (0abe7ee)
  • init api models (624eed9)
  • Write glue code to link generated code (GHORG-15) (#9) (994d0ea)