Skip to content

Installation

Before installing the SDK, make sure your toolchain meets the following minimum versions:

  • Bun: 1.2.0 or newer (preferred)
  • Node.js: 22.0.0 or newer (if you run builds/tests under Node)
  • TypeScript: 5.6.x or newer for the best inference and project references

Add the dependency

bash
bun add @selling-partner-api/sdk
# or, if you are still on npm
npm install @selling-partner-api/sdk

The package ships as pure ESM. If you rely on CommonJS, convert your project or use dynamic import() calls.

Need direct access to the raw OpenAPI surface? Install the published models package alongside the SDK:

bash
bun add @selling-partner-api/models
# or
npm install @selling-partner-api/models

This dependency exposes both the generated paths.ts TypeScript definitions and the merged OpenAPI document (import merged from "@selling-partner-api/models/merged.json").

Installing from GitHub Packages

GitHub Packages mirrors the same builds published to npm. To install directly from GitHub, add the scope-specific registry to your .npmrc:

ini
@selling-partner-api:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}

Then install with any npm-compatible client (npm, pnpm, yarn, bun). Set NODE_AUTH_TOKEN to a personal access token that has packages:read permission for the selling-partner-api organization.

Workspace layout

When cloning this repository, the SDK lives in packages/sdk. The root uses Bun workspaces, so the following commands install everything in one go:

bash
bun install
bun run build:sdk

The build step will:

  1. Regenerate rate-limit metadata from packages/sdk/src/assets/rate-limits.json.
  2. Compile TypeScript sources into packages/sdk/dist.
  3. Emit .d.ts files alongside the ESM output.

Environment variables

At runtime the SDK expects the following values:

VariableDescription
SP_CLIENT_IDLogin With Amazon (LWA) client ID
SP_CLIENT_SECRETLWA client secret
SP_REFRESH_TOKENRefresh token obtained during seller authorization
SP_REGIONOne of eu, na, or fe

You can provide these directly when constructing SpApi, but keeping them in environment variables simplifies deployments and local testing.

Monorepo usage

If you publish your own packages from the same repository, consume the SDK via the workspace protocol:

json
{
  "dependencies": {
  "@selling-partner-api/sdk": "workspace:*"
  }
}

This ensures local builds use the current source while release workflows publish the compiled output.

Community-maintained guidance for builders on the Amazon SP-API.