TypeScript SDK Overview

Build commerce applications with TypeScript

About the TypeScript SDK

The TypeScript SDK provides an easy interface for interacting with the commercetools Composable Commerce APIs. All HTTP API endpoints are supported.

This SDK is autogenerated as a TypeScript library using our open source code generator. Based on the REST modeling framework, the TypeScript SDK gives you faster support for newly released API features and quicker bug fixes.

Additionally, it has exclusive support for the Machine Learning APIs and the Import API.

JavaScript and Node SDKs

Previous versions of this SDK include the JavaScript SDK V1 and the Node SDK. You can find more information about these SDKs in Previous versions.

Features

Middleware

Middleware can be used to fit your development requirements. You can use them together, create your own custom versions, or choose only one of them. For example, if you don't need authentication, but you need to send HTTP requests.

The following table displays the middleware, what it does, and what properties can be configured.

For importing, configuring, and implementing middlewares, refer to the get started guide.

MiddlewareDescription and properties
HttpMiddlewareOptionsSends HTTP requests.
  • host : string (API URL of your Region)
  • credentialsMode ? : 'omit' | 'same-origin' | 'include'
  • enableRetry ? : boolean
  • fetch ? : any
  • getAbortController ? : () => AbortController
  • includeHeaders ? : boolean
  • includeOriginalRequest ? : boolean
  • includeRequestInErrorResponse ? : boolean
  • includeResponseHeaders ? : boolean
  • maskSensitiveHeaderData ? : boolean
  • retryConfig ? : { backoff?, maxDelay?, maxRetries?, retryDelay?, retryCodes? }
  • timeout ? : number
AuthMiddlewareOptionsAuthenticates requests.
  • credentials : { clientID, clientSecret, anonymousId? }
  • host : string (Auth URL of your Region)
  • projectKey : string
  • scopes ? : Array<string>
QueueMiddlewareOptionsThrottles concurrent requests, which is useful for reducing concurrent HTTP requests.
  • concurrency : number
UserAgentMiddlewareOptionsSets the User-Agent to requests.
  • contactEmail ? : string
  • libraryName ? : string
  • libraryVersion ? : string
  • contactUrl ? : string
CorrelationIdMiddlewareOptionsAdds a correlation id to requests.
  • generate: () => string
withLoggerMiddleware()Logs incoming requests and response objects. Include this method when creating the ClientBuilder.

Get the source on GitHub

The TypeScript SDK is fully open source and is available from GitHub.

License

The TypeScript SDK is provided under the MIT License.

Changelog

The changelog for the TypeScript SDK can be found at GitHub.

Contribute to the TypeScript SDK

We welcome any kind of contribution, including reporting issues, submitting bug fixes, providing ideas for new features, or suggestions for improvements. You can learn more about contributing to the TypeScript SDK at GitHub.

A full list of contributors can be found here.

Best practices

  • Ensure the TypeScript SDK is up to date.
  • Read the documentation carefully to correctly and properly implement or integrate the SDK.
  • Report issues as soon as they are noticed or spotted at the GitHub repository.
  • If you encounter an issue that is urgent or critical for your business, create a support request at the Support Portal.
  • Provide as many details as possible with your issue reports, including the SDK version, the specific error message, any log or stack traces, and the code snippet that causes the issue.

A complete list of best practices can be found at GitHub.