Writing front-end API code with Postman


Writing code is hard. Mistakes creep in due to a myriad of reasons. Making API calls through code is harder still. Ensuring that complex API calls go through perfectly requires a lot of trial and error. Of course, with Postman you can verify whether your backend API is working without writing any code. But what happens when you have to write code for your frontend app? The complexity is illustrated by the number of Stack Overflow questions that mention “postman”.

Starting with Postman 3.0, Postman lets you generate code snippets in more than 15 languages. The code generator is powered by a fork of Mashape’s httpsnippet library. While code snippets in API documentation pages are helpful, they don’t fit your specific use case. Coupled with Postman’s powerful request builder now you can generate frontend API code in seconds. We maintain this fork actively and if you want to contribute to it, head to Github. The code generator can be accessed through the button on the bottom right part of the request builder.


The code generator will also make for a great companion if you are writing API documentation. We would also suggest that you distribute a Collection file with documentation so that developers can generate sample code within Postman itself. Of course, you would also be calling APIs in your backend. The process for doing this with Postman remains the same.


For existing users of Postman who are used to the ‘Preview’ feature, the curl and HTTP preview options are part of the code generator now.

We hope that you like this feature. Let us know your suggestions in the comments and do follow us on Twitter!


Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

3 thoughts on “Writing front-end API code with Postman


    Is it also possible to implement token authentication, e.g. capture the returned token info and resend it as a header? I would like to be able to test my Rails API applications using standard devise, any suggestions on how to do this?


    Really appreciate this feature! Noticed it a few weeks ago and was pleasantly surprised to see you had added code gen and were using the httpsnippet lib.