API Reference
This section documents the SDK packages APIs.
Importing
Every function described in each package below is a top-level export. You can import any of them like this:
ES6
import { createClient } from '@commercetools/sdk-client'
ES5 (CommonJS)
var createClient = require('@commercetools/sdk-client').createClient
ES5 (UMD build)
// We recommend to use https://unpkg.com as CDN
var createClient = CommercetoolsSdkClient.createClient
Core
sdk-client
Core package to enable executing HTTP request. To be used together with middlewares.
Middlewares
It's up to you to pick whatever middleware fits your needs: you can compose them together, create your own custom versions, choose only one of them (e.g. you might not need authentication, but you need to send http requests).
sdk-middleware-auth
Middleware to authenticate the request using one of the supported auth flows.
- createAuthMiddlewareForClientCredentialsFlow(options)
- createAuthMiddlewareForPasswordFlow(options)
- createAuthMiddlewareForRefreshTokenFlow(options)
- createAuthMiddlewareForAnonymousSessionFlow(options)
- createAuthMiddlewareWithExistingToken(authorization, options)
sdk-middleware-http
Middleware to send the actual HTTP request.
sdk-middleware-queue
Middleware to throttle concurrent request to a certain limit. Useful to reduce concurrent HTTP requests.
sdk-middleware-logger
Middleware to log incoming request and response objects.
sdk-middleware-user-agent
Middleware to automatically set the User-Agent
to the request.
sdk-middleware-correlation-id
Middleware to add a correlation id to requests.
Helpers
Those are optional packages that provides help building the final request. You can choose to use them but you don't have to.
api-request-builder
Provides an API to construct a URI for the HTTP API endpoints in a declarative way. Useful for building request uri
for requests.
http-user-agent
Creates a proper HTTP User-Agent. Can be used everywhere.
sync-actions
Provides an API to construct update actions. Useful for building request body
for updates.
- createSyncCategories(actionGroups)
- createSyncCustomers(actionGroups)
- createSyncInventories(actionGroups)
- createSyncProducts(actionGroups)
- createSyncOrders(actionGroups)
- createSyncDiscountCodes(actionGroups)
- createSyncProductDiscounts(actionGroups)
- createSyncCustomerGroup(actionGroups)
- createSyncCartDiscounts(actionGroups)