Skip to main content


This is the interactive tutorial for Konfig.

How to use this tutorial​

On the left are the directions for the tutorial.

On the right is an interactive development environment to execute commands and edit files.

At the top of the development environment, you will see a file editor.

And at the bottom of the development environment, you will see a terminal.

Tutorial layout

Each section will present a new topic for generating SDKs with Konfig. Later steps require the completion of earlier ones, so you must go from start to finish.

Click the button below to go to the next step.

The Problem​

APIs can be difficult to integrateβ€”especially when an API has hundreds of operations and data models. Nowadays, API-first companies publish SDKs because it accelerates integration and converts more customers.

The Old Way​

This is what it looks like to integrate with your API without an SDK. We are manually importing a request library, constructing request bodies, and constructing HTTP requests.


import axios from 'axios';
let data = JSON.stringify({
quantity: '1,000',
let config = {
method: 'post',
maxBodyLength: Infinity,
url: '',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
data: data,

Run the following command in the terminal to execute the code to make a request.


ts-node make-request.ts

Oh shoot! It didn't even work, and we got an ambiguous error.


data: { code: 500, type: 'unknown', message: 'something bad happened' }

After hours of debugging, we discover that we need to pass the number 1000 instead of the string "1,000". Debugging these sorts of issues is frustrating and leads to a longer time to value and ultimately lower conversions 😀.


let data = JSON.stringify({
- quantity: '1,000',
+ quantity: 1000,

Try again​

Run the following command again.


ts-node make-request.ts

Now we should get the expected output.


❯ ts-node make-request.ts
Place Order Response: {"id":12,"petId":0,"quantity":1000,"complete":false}

The New Way​

Instead, your customers should be using an SDK.


import { Petstore } from "petstore";
new Petstore().store.placeOrder({
quantity: 1000
}).then(response => {
console.log("Place Order Response:",;

The above SDK example is strongly typed and simplified. But...SDKs are time-consuming to create and maintain.

The Solution: Konfig​

Konfig is a tool for generating SDKs for your API from the OpenAPI Specification and Postman Collection Format.

To generate SDKs, we created a CLI which has been installed in your development environment.

To control how the SDKs are generated, we created a file type called konfig.yaml. This file specifies things such as target languages or SDK versions.

OpenAPI Specification​

For this tutorial, we are using an OpenAPI Specification for an API that manages a Petstore. You can examine the API in the development environment.

Create a konfig.yaml​

To get started generating a TypeScript SDK, run the following command in the terminal.


konfig init

You will be prompted to specify what languages to generate SDKs in.

Language Prompt

For this demo, we will only generate a TypeScript SDK. Type a to de-select all languages. Then use the down arrow and space to select TypeScript. Press enter to proceed.

Next, you will be prompted with a few questions on how to name your SDK package, the Git repository details, and path to your OpenAPI Specification file.

You can use the following answers for this tutorial:


? What is the SDK package name? ... petstore
? What is your Git user ID? petstore
? What is your Git repository name? petstore-sdks
? What is the relative path to your spec? ... api.yaml

About konfig.yaml​

Now we have a konfig.yaml file that includes:

  1. The path to your OpenAPI Specification

specPath: api.yaml

  1. Configuration to generate a TypeScript SDK

version: 1.0.0
npmName: petstore-typescript-sdk
outputDirectory: typescript
clientName: Petstore
userId: petstore
repoId: petstore-sdks/tree/main/typescript

Now we are ready to generate our TypeScript SDK.

Generate a TypeScript SDK​

To generate your TypeScript SDK, run the following command.


konfig generate

You should see the following output.


Output directory set to: /tmp/petstore-sdks-out
Generating typescript SDKs... done
Downloading 1 SDKs... done
Deleting output directory... done
Creating output directory... done
Extracting SDKs... done
Deleting contents of existing directory "typescript"... done
Copying Typescript SDK to "typescript"... done
Generating top-level
Generating top-level done
Writing top-level LICENSE... done

The Generated SDK​

Konfig's generated SDKs are crafted to feel ergonomic and include comprehensive documentation so your customers are delighted throughout the integration.

Take a look at the typescript/ folder to see the generated code.

TypeScript SDK

Finally, let's refactor the make-request.ts implementation to use the generated SDK.

Refactored Implementation​

We refactored make-request.ts to use the SDK you generated. Check your file editor to see the new implementation.


import { Petstore } from "petstore";
new Petstore().store.placeOrder({
quantity: "1,000"
}).then(response => {
console.log("Place Order Response:",;

To build the SDK and run the refactored implementation, execute the following command.


cd typescript/ && yarn && yarn build && cd ../ && ts-node make-request.ts


We need to run yarn && yarn build to compile the TypeScript SDK to JavaScript.

This time, we caught an error at compile time that tells us quantity should be a number.


make-request.ts:5:5 - error TS2322: Type 'string' is not assignable to type 'number'.
5 quantity: '1,000',
34 'quantity'?: number;
The expected type comes from property 'quantity' which is declared here on type 'Order'

Fixing the compilation error should let us make the request.

Try again​

Run the following command to test the fixed implementation.


ts-node make-request.ts

You should see the following output.


❯ ts-node make-request.ts
Place Order Response: { id: 14, petId: 0, quantity: 1000, complete: false }

Woohoo, the SDK works!


In this tutorial, we learned about the benefits of SDKs, generated an SDK from scratch, and refactored an implementation using the generated SDK πŸŽ‰.

Further Reading​

When doing this on a real API you will need to make modifications to your OpenAPI Specification to generate high-quality SDKs. Konfig also makes this easy through its lint and fix utilities. You may also want to setup Continuous Deployment through GitHub Action or polling. And sometimes it's also necessary to add business logic to your SDKs, which is also made easy by Konfig through our support for customization.