# Client SDKs

An official client SDK for fulfillmenttools is provided, and clients can also be generated using third-party tools.

## fulfillmenttools SDK

The official fulfillmenttools client SDK in TypeScript is available on [GitHub](https://github.com/fulfillmenttools/fulfillmenttools-sdk-typescript) and [npm](https://www.npmjs.com/package/@fulfillmenttools/fulfillmenttools-sdk-typescript) and can be used wherever you run JavaScript.

The TypeScript SDK is open source and licensed under the MIT License, so you can use it in your projects and contribute to its development.

{% hint style="info" %}
Learn how to set up and use the TypeScript SDK with the [tutorial on GitHub](https://github.com/fulfillmenttools/fulfillmenttools-sdk-typescript/blob/main/TUTORIAL.md).
{% endhint %}

Currently, this client SDK doesn't provide access to all of our API's features, but we're continuously extending it and releasing new versions. We welcome your feedback.

## Client generation

Another approach is to use [Swagger Codegen](https://swagger.io/tools/swagger-codegen/), which can generate client SDKs from our OpenAPI specification.

Other tools, such as the [OpenAPI Generator](https://openapi-generator.tech/), can also be used. It is also possible to opt out of generating `classes` or `types` and instead manually model the required components for a specific use case.

{% hint style="info" %}
The Swagger [Codegen GitHub repository](https://github.com/swagger-api/swagger-codegen) has more details on this tool.
{% endhint %}

### TypeScript example

Here's an example workflow to generate a TypeScript client from our OpenAPI specification:

{% stepper %}
{% step %}
**Follow prerequisites**

Follow the [Swagger Codegen CLI Tool instructions](https://github.com/swagger-api/swagger-codegen#prerequisites) on GitHub.
{% endstep %}

{% step %}
**Download the OpenAPI specification**

Download the fulfillmenttools OpenAPI specification:

* <https://raw.githubusercontent.com/fulfillmenttools/fulfillmenttools-api-reference/master/api.swagger.yaml>
  {% endstep %}

{% step %}
**Generate the TypeScript client**

Use the Swagger Codegen CLI tool to generate a TypeScript client. Example command:

{% code title="Generate TypeScript client" %}

```bash
java -jar swagger-codegen-cli-3.0.62.jar generate \
  -i api.swagger.yaml \
  -l typescript-fetch \
  -o client
```

{% endcode %}

This will put the generated classes into the `client` folder. In this folder, the `api.ts` file contains the generated namespaces, interfaces, and related code that are especially relevant.
{% endstep %}

{% step %}
**Review and integrate**

Depending on your preferences, you can:

* Use all the generated client classes
* Pick only the generated `enum`, `interface`, `namespace`, `type` definitions, and implement the actual client yourself

{% endstep %}
{% endstepper %}

### TypeScript example

This example demonstrates how to generate a TypeScript client:

1. Follow the [Swagger Codegen CLI Tool instructions](https://github.com/swagger-api/swagger-codegen#prerequisites) on GitHub.
2. Download the fulfillmenttools OpenAPI specification [api.swagger.yaml](https://raw.githubusercontent.com/fulfillmenttools/fulfillmenttools-api-reference/master/api.swagger.yaml).
3. Use the Swagger Codegen CLI tool to generate a TypeScript client:

   ```shell
   java -jar swagger-codegen-cli-3.0.62.jar generate \
     -i api.swagger.yaml \
     -l typescript-fetch \
     -o client
   ```
4. This command generates the client classes in the `client` folder. Within this folder, the `api.ts` file contains the generated `namespaces` and `interfaces`.
5. It is possible to use all the generated client classes, or to selectively use the generated `enum`, `interface`, `namespace`, and `type` definitions to implement a custom client.
