Generate SDKs for APIs with Postman’s new Konfig integration
For many developers, figuring out how to integrate their product with an API is difficult. Some challenges they may run into include:
- Incorrectly constructing the HTTP request.
- Introducing typos when creating complex request bodies.
- Passing incorrect data types to the API.
- Serializing requests and deserializing responses.
- Translating API documentation to code.
If you want to grow your API product, you need to provide a great developer experience to help your customers easily start using your API. Best-in-class API companies like Stripe and Plaid have already figured this out and offer SDKs to onboard customers quickly. But publishing SDKs in all of the most popular languages can take endless engineering hours, especially if your team is not fluent in many programming languages.
What is an SDK?
SDKs make API integration easier by packaging boilerplate code in each programming language that developers can then import into their IDE. Integrating an API with an SDK offers significant benefits, such as fewer lines of code and strong typing:
By creating SDKs for your API, you can save months of onboarding time for your customers and win more potential deals.
The state of SDK tooling for APIs
As the demand for APIs continues to soar, existing solutions for automatically creating SDKs fall short in providing high-quality code that is tailored for API companies. Although there are many open source solutions based on the OpenAPI Specification, none of them generate the quality of code your customer would want; in fact, the generated outputs sometimes won’t even compile. Furthermore, there are little to no solutions for generating high-quality SDKs if you don’t have and maintain an OpenAPI Specification that describes your API (i.e., if you only have a Postman Collection).
The solution: Konfig
Konfig is a tool for generating SDKs for your API from the OpenAPI Specification or Postman Collection format. By using Konfig, your customers will:
- Spend less time integrating your API.
- Have access to documentation in the IDE.
- Catch bugs sooner in development.
- Write less code.
- Require less support throughout onboarding.
Konfig created a CLI that can be used to easily generate SDKs while also integrating seamlessly with your CI/CD infrastructure. The Konfig CLI ingests either your OpenAPI Specification or Postman Collection and uses it to automatically generate, test, and publish SDKs in whatever languages you want. With Konfig, it only takes minutes to create high-quality SDKs for your API, saving you countless engineering hours and giving your API a best-in-class developer experience.
Creating your first SDK from Postman
To get started, you will need shell access to a machine with Node 14+ installed.
Export your collection
Click the settings for your collection and select Export:
Then, select Collection v2.1 and Export:
Install Konfig’s CLI with npm or yarn
To use npm, enter this command:
Alternatively, you can use yarn with this command:
Initialize an SDK directory
Create a directory for SDKs with the following command:
Then, copy the collection you exported from Postman to your SDK directory:
Next, convert your collection to an OpenAPI Specification:
Now, run the following command to initialize Konfig:
You will be asked a series of questions, such as which languages to generate SDKs for, the package name of your SDKs, your Git repository information, and the path to your OpenAPI Specification:
To ensure your OpenAPI Specification can produce a high-quality SDK, run the below command:
konfig generate to generate your SDKs:
You should now see the following output from generating your SDK:
After successfully generating your SDKs, you should see a folder for each one:
Next steps with Konfig
Congratulations on generating your first SDK with Konfig! To deliver your SDKs to customers, you need to publish them to public package managers. You might also want to automate the entire process so your SDKs stay in sync with your API. Konfig makes both of these steps easy by seamlessly integrating with your CI/CD pipeline.
To learn more about how to easily generate SDKs for your API, check out Konfig’s documentation.