Generate code snippets from API requests

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.

Contents

Generate code snippets in Postman

  1. Open the request you want to use for a code snippet, then select the code icon Code icon in the right pane.

    Open code snippets
  2. Select a language or framework from the dropdown list.

  3. Select the copy icon Copy icon to copy the code snippet to your clipboard.

    Copy code snippet to clipboard
  4. For more configuration options, like the indentation type and count, select the settings icon Settings icon next to the dropdown list. The settings vary based on the chosen language or framework.

Supported languages and frameworks

Postman supports the following:

LanguageFramework
CLibCurl
C#HttpClient
C#RestSharp
cURLcURL
DartDart
Gohttp package
HTTP(Raw HTTP request)
JavaOkHttp
JavaUnirest
JavaScriptFetch
JavaScriptjQuery
JavaScriptXHR
NodeJSAxios
NodeJSNative
NodeJSRequest
NodeJSUnirest
Objective-CNSURLSession
OCamlCohttp
PHPcURL
PHPGuzzle
PHPHttp_Request2
PHPpecl_http
PowerShellRestMethod
Pythonhttp.client (Python 3)
PythonRequests
Rhttr
RRCurl
RubyNET::Http
ShellHttpie
Shellwget
SwiftURLSession

To add a new language or setting, you can contribute to Postman's open-source project.

Last modified: 2024/02/05