API client
Code snippets
Generate code for any API client request in 20 languages and tools, including cURL, Python, JavaScript, Go and Swift, with or without its variables filled in.
Code snippets turn a request into code you can paste into an app, a script or a bug report. Pick a language and the client writes the same method, URL, headers and body in that language’s usual HTTP library.
Get a snippet
Section titled “Get a snippet”- Open an HTTP or GraphQL request.
- Click Code in the request’s header.
- Pick a language from the menu. The client remembers your choice for next time.
- Click Copy, then Done.
The Code snippet sheet.
- Language
- Fill in variables, or keep {{names}}
- The generated code
- Auth isn't included
- Copy to the clipboard
For a quick cURL command, right-click a request in the sidebar and choose Copy as cURL. It copies the request with variables filled in.
Languages
Section titled “Languages”| Menu name | Produces |
|---|---|
| cURL | A curl command for the shell. |
| Swift | URLRequest and URLSession with async/await. |
| JavaScript | fetch. |
| Python | The requests library. JSON bodies become a Python dictionary. |
| Go | net/http. |
| HTTPie | An http command. |
| Shell – wget | A wget command. |
| HTTP | The raw HTTP request. |
| NodeJS – Axios | Axios. |
| Python – http.client | Python’s standard-library http.client. |
| Java – OkHttp | OkHttp. |
| Kotlin – OkHttp | OkHttp from Kotlin. |
| C# – HttpClient | .NET HttpClient. |
| PHP – cURL | PHP’s cURL functions. |
| Ruby – Net::HTTP | Ruby’s Net::HTTP. |
| Rust – reqwest | The reqwest crate. |
| Dart – http | The http package. |
| PowerShell | Invoke-RestMethod. |
| C – libcurl | libcurl from C. |
| Markdown | A heading with the method and URL, a table of headers and the body in a code block, for docs and issues. |
What’s in a snippet
Section titled “What’s in a snippet”The snippet is the request as it would be sent, minus anything that only happens when you click Send.
| Included | Not included |
|---|---|
| Method and URL, with query params | Auth from the Authorization tab, or inherited from a folder or collection |
| Enabled headers | Pre-request and post-response scripts, and their changes |
| The body, when it’s text | Cookies from the client’s cookie jar |
The Content-Type the body type adds |
Request settings such as timeouts and TLS verification |
| Path variable values |
Except in cURL and Markdown, snippets leave out the Host, Content-Length, Connection, Proxy-Connection and Accept-Encoding headers, which HTTP libraries set themselves.
To include auth in a snippet, add the header yourself on the Headers tab, for example Authorization: Bearer {{token}}. The sheet reminds you: “Auth headers are added when the request is sent, so they aren’t in the snippet unless set as headers.”
Fill in variables
Section titled “Fill in variables”Fill in variables is on by default. It replaces {{variables}} with their current values from the active environment, collection and globals, along with Vault secrets and fresh dynamic values. Turn it off to keep {{baseUrl}} and the rest as written, which is better for documentation and for sharing. Path variables are filled in either way.
Other places to get code
Section titled “Other places to get code”- Exported HTML docs include a snippet for every request in ten of these languages, with variables kept as written. See Examples and docs.
- Captured traffic in the proxy can be copied as code too. See Copy as code.
- Whole client libraries: Generate SDK on a collection writes a TypeScript, Python or Swift SDK. See Generate docs, SDKs and MCP servers.