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
bun add @selling-partner-api/sdk
# or, if you are still on npm
npm install @selling-partner-api/sdkThe 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:
bun add @selling-partner-api/models
# or
npm install @selling-partner-api/modelsThis 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:
@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:
bun install
bun run build:sdkThe build step will:
- Regenerate rate-limit metadata from
packages/sdk/src/assets/rate-limits.json. - Compile TypeScript sources into
packages/sdk/dist. - Emit
.d.tsfiles alongside the ESM output.
Environment variables
At runtime the SDK expects the following values:
| Variable | Description |
|---|---|
SP_CLIENT_ID | Login With Amazon (LWA) client ID |
SP_CLIENT_SECRET | LWA client secret |
SP_REFRESH_TOKEN | Refresh token obtained during seller authorization |
SP_REGION | One 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:
{
"dependencies": {
"@selling-partner-api/sdk": "workspace:*"
}
}This ensures local builds use the current source while release workflows publish the compiled output.