Postman can convert an API request into a code snippet. You can then use the generated code snippet in your front-end application to make calls to an API. Postman can generate code snippets for a variety of programming languages and frameworks, including C#, JavaScript, and NodeJS.
This guide has information about generating code snippets from API requests. For information about generating server-side boilerplate code from an API specification, see Generate server-side code from your OpenAPI 3.0 definition.
Open the request you want to use for a code snippet, then select Code in the right sidebar.
Select a language or framework from the dropdown list.
Select Copy snippet to copy the code snippet to your clipboard.
For more configuration options, like the indentation type and count, select Code settings next to the dropdown list. The settings vary based on the chosen language or framework.
Postman supports the following:
Language | Framework |
---|---|
C | LibCurl |
C# | HttpClient |
C# | RestSharp |
cURL | cURL |
Dart | Dart |
Go | http package |
HTTP | (Raw HTTP request) |
Java | OkHttp |
Java | Unirest |
JavaScript | Fetch |
JavaScript | jQuery |
JavaScript | XHR |
NodeJS | Axios |
NodeJS | Native |
NodeJS | Request |
NodeJS | Unirest |
Objective-C | NSURLSession |
OCaml | Cohttp |
PHP | cURL |
PHP | Guzzle |
PHP | Http_Request2 |
PHP | pecl_http |
PowerShell | RestMethod |
Python | http.client (Python 3) |
Python | Requests |
R | httr |
R | RCurl |
Ruby | NET::Http |
Shell | Httpie |
Shell | wget |
Swift | URLSession |
To add a new language or setting, you can contribute to Postman's open-source project.
Last modified: 2024/02/05
Additional resources
Videos
Blog posts
Case Studies