Platform

Code generation for API requests in 30 languages and libraries

Once a request works in Swastik Codes, the code snippet panel turns it into code you can paste into your project or a terminal. Pick a language and library and the snippet includes the method, URL, query parameters, headers, body and authentication.

Get started freeSign inOpen the app

Supported languages and libraries

LanguageTargets
ShellcURL, Wget, HTTPie, PowerShell (Invoke-RestMethod)
RawHTTP request text
JavaScriptFetch, Axios, jQuery, XHR
Node.jsnative http, Axios
PythonRequests, http.client
Gonet/http
JavaOkHttp, Unirest, java.net.http
C#HttpClient, RestSharp
PHPcURL, Guzzle
RubyNet::HTTP
SwiftURLSession
KotlinOkHttp
Darthttp
Rustreqwest
Clibcurl
Rhttr, RCurl
OCamlCohttp

Variables and auth resolved for you

Turn on variable resolution and snippets are generated with your current values substituted, so {{baseUrl}}/users/{{userId}} becomes a real URL; leave it off to keep the {{placeholders}}. The request's auth, including auth inherited from its folder or collection, is applied: a Bearer token becomes an Authorization header and an API key lands in the header or query string you configured. Generating code never sends the request.

For example, a JSON POST with a bearer token as Python Requests:

Python
import requests

url = "https://api.example.com/v1/orders"
payload = {"sku": "A-1", "quantity": 2}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer eyJhbGciOi...",
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)

Every body type

Snippets cover JSON and other raw bodies, x-www-form-urlencoded fields, multipart form-data with file fields, binary bodies and GraphQL queries with variables, each written the idiomatic way for the chosen library where it has one.

Code samples in published docs

The same generator powers the code samples in published API documentation. Readers choose their language and get a snippet for every request, so your docs and the app never disagree.

Go the other way: paste cURL

Code generation has a natural counterpart: paste a cURL command into the import dialog (or straight into the URL bar) and Swastik Codes turns it into a request with the same method, headers and body. That makes it easy to move a request between a terminal, a teammate's message and your collection. See import and export.

How it works

  1. Open any request in the app.
  2. Open the code snippet panel and pick a language.
  3. Copy the snippet into your code or terminal. When you are ready to send from Swastik Codes itself, create a free account.

Frequently asked questions

Does the snippet include my secrets?

If you generate with variables resolved, the snippet can contain the real values, including tokens. Be careful where you paste it, and rotate any token that ends up in a public place.

Which cURL flags are generated?

The method, headers, body (--data, --form or --data-binary as appropriate) and URL, quoted for a POSIX shell. PowerShell has its own target.

Can I generate a full SDK?

No. Code generation produces a snippet per request. For a full client library, export your collection to OpenAPI 3 and use an OpenAPI code generator.

Is gRPC code generation supported?

For gRPC requests you can copy a grpcurl command from the gRPC client.

Try it on your own API

Swastik Codes runs in the browser and is free to use. Create an account to send requests, sync your workspaces and invite your team.