How to handle different API versions
mainThe client defaults to the oldest available version of an endpoint to prevent breaking changes. To use a newer version, you have two options:
- Per-call: Specify the
versioninside theoptionsobject of.callAPI(). - Class-level: Set
endpoints_versionsin theSellingPartnerconstructor to enable a specific version for all operations of that endpoint.
If version_fallback is set to true (default), the client will automatically attempt to find an operation in an earlier version if it is missing from the version you specified.
// Option 1: Per-call versioning
let res = await spClient.callAPI({
operation: 'getCatalogItem',
endpoint: 'catalogItems',
path: { asin: 'B084DWG2VQ' },
options: { version: '2020-12-01' }
});
// Option 2: Class-level versioning
const spClient = new SellingPartner({
region: 'eu',
refresh_token: '<REFRESH_TOKEN>',
endpoints_versions: {
catalogItems: '2020-12-01'
}
});