Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@sp-api-sdk/common

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sp-api-sdk/common

Selling Parner API common library

Source
npmnpm
Version
2.1.30
Version published
Weekly downloads
3.6K
-58.58%
Maintainers
1
Weekly downloads
 
Created
Source

@sp-api-sdk/common

npm version XO code style

Amazon Selling Partner API common package

Bizon

Installing

npm install @sp-api-sdk/common

Note: You typically do not need to install this package directly. It is automatically included as a dependency of every API client package.

Overview

This package provides the shared infrastructure used by all API client packages:

  • Axios instance factory with authentication, rate limiting, logging, and error handling
  • Region configuration for NA, EU, and FE endpoints (production and sandbox)
  • Error handling with SellingPartnerApiError

Client Configuration

The ClientConfiguration interface is used by all API client constructors:

import { type ClientConfiguration } from "@sp-api-sdk/common";
OptionTypeRequiredDescription
authSellingPartnerApiAuthYesAuthentication instance from @sp-api-sdk/auth
region'na' | 'eu' | 'fe'YesSelling Partner API region
sandboxbooleanNoUse sandbox endpoints (default: false)
rateLimitingobjectNoRate limiting retry configuration
loggingobjectNoRequest/response/error logging configuration
restrictedDataTokenstringNoRestricted Data Token for accessing PII
userAgentstringNoCustom user-agent header

Regions

Three regions are supported, each with production and sandbox endpoints:

RegionCodeAWS RegionProduction Endpoint
North Americanaus-east-1https://sellingpartnerapi-na.amazon.com
Europeeueu-west-1https://sellingpartnerapi-eu.amazon.com
Far Eastfeus-west-2https://sellingpartnerapi-fe.amazon.com

When sandbox is set to true, the sandbox variant of the endpoint is used (e.g. https://sandbox.sellingpartnerapi-eu.amazon.com).

Rate Limiting

When rateLimiting.retry is enabled, the SDK automatically retries HTTP 429 responses. The retry delay is calculated as follows:

  • If the response includes an x-amzn-ratelimit-limit header, the delay is derived from it.
  • Otherwise, the SDK falls back to the documented rate limits for the specific endpoint.
  • If no rate limit information is available, a 60-second default delay is used.

You can optionally provide an onRetry callback to be notified on every retry:

rateLimiting: {
  retry: true,
  onRetry: ({delay, rateLimit, retryCount, error}) => {
    console.log(`Retry #${retryCount}, waiting ${delay}ms (rate limit: ${rateLimit})`)
  },
}

Logging

Logging is powered by axios-logger and can be configured independently for requests, responses, and errors:

logging: {
  request: true,   // or a RequestLogConfig object
  response: true,  // or a ResponseLogConfig object
  error: true,     // or an ErrorLogConfig object
}

Pass true to use sensible defaults (no headers logged for requests, headers logged for responses). Pass a configuration object to customize the behavior.

By default, request and response loggers use console.info, and the error logger uses console.error.

Warning: Enabling headers: true in the request logger will log authentication tokens. This should be disabled in production.

Error Handling

API errors are wrapped in SellingPartnerApiError, which extends AxiosError and adds context:

import { SellingPartnerApiError } from "@sp-api-sdk/common";

try {
  await client.getOrders({ marketplaceIds: ["A1PA6795UKMFR9"] });
} catch (error) {
  if (error instanceof SellingPartnerApiError) {
    console.error(error.message); // e.g. "orders (v0) error: Response code 403"
    console.error(error.apiName); // e.g. "orders"
    console.error(error.apiVersion); // e.g. "v0"
    console.error(error.innerMessage); // Original axios error message
  }
}

License

MIT

Miscellaneous

    ╚⊙ ⊙╝
  ╚═(███)═╝
 ╚═(███)═╝
╚═(███)═╝
 ╚═(███)═╝
  ╚═(███)═╝
   ╚═(███)═╝

Keywords

bizon

FAQs

Package last updated on 11 Mar 2026

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