What is an API request code generator?
An API request code generator writes the code to call an HTTP API from a simple description of the request. It saves looking up each library's syntax and avoids quoting mistakes, which is handy when documenting an API, sharing a reproducible example or moving a call between languages.
Choose the method, enter the URL, and add query parameters and headers as name and value pairs. For methods that carry a body, pick JSON, form fields or text. Code appears for cURL, JavaScript fetch, Axios, Python requests, HTTPie and PowerShell, and updates as you edit.
How to use the API request code generator
1.Fill in the request
Method, URL, query parameters and headers.
2.Add a body
JSON, form fields or raw text for POST, PUT and PATCH.
3.Pick a language and copy
Switching languages keeps the same request.
Example: creating an order
POST https://api.example.com/v1/orders?notify=true with a bearer token and a JSON body:
- cURL
- curl -X POST '…/orders?notify=true' -H 'Authorization: Bearer …' --data-raw '{…}'
- Python
- requests.post(url, headers={…}, json={"sku": "LMP-01", "qty": 2}, timeout=30)
- Content-Type
- added automatically as application/json
One request, correct in six languages.
Quoting done right
Generated code handles the fiddly parts: shell quoting of apostrophes for cURL and HTTPie, URL-encoding query parameters, JSON bodies rendered as native objects in fetch, Axios and Python, Python's True, False and None, and the right Content-Type header added automatically.
Form bodies are typed as name=value lines and sent URL-encoded. To turn an existing cURL command into code instead, use the cURL converter. To actually send the request and see the response, use the API tester.
Frequently asked questions
Does it send the request?
No. It only writes code. The API tester sends requests.
Is it safe to type my API key?
It stays in this page, but generated code contains it, so don't share or commit that code.
Why does Python use json= instead of a header?
requests sets Content-Type: application/json itself when you pass json=.
Can I add file uploads?
Not yet. Multipart uploads need a file, so write those by hand.
Related tools
API tester
Send HTTP requests from your browser and inspect status, timing, headers and body.
cURL to Code Converter
Convert cURL commands to JavaScript fetch, axios or Python requests.
Query string builder and parser
Parse a URL's query parameters, or build an encoded query string from key = value lines.
HTTP status codes
Every HTTP status code with its name and plain-English meaning.
HTTP headers reference
Common HTTP request and response headers explained, from caching to CORS.
MIME type lookup
Find the MIME type for a file extension, or the extension for a MIME type.
More Developer tools
JSON & data
CSV tools
Network & system
Web & API
Git & releases
Encoding & security
- Base64 encode & decode
- URL encode & decode
- JWT decoder
- Hash generator
- HTML entity encoder
- Text to binary
- Morse code translator
- Caesar cipher & ROT13
- Random string generator
- Secret key generator
- 2FA code generator (TOTP)
- Encrypt & decrypt text
- Encrypt & decrypt files
- SSH key generator
- Base32 encoder and decoder
- Unicode escape converter
- Nano ID generator
- JWT generator
Text & code
- Regex tester
- Text diff checker
- Cron expression explainer
- Lorem ipsum generator
- Markdown previewer
- Slug generator
- Strip HTML tags
- Unicode character inspector
- URL parser
- Markdown TOC generator
- Whitespace visualizer
- Markdown link extractor
- Regex escape
- Regex match extractor
- Split text by regex
- HTML, CSS and JS playground
- Mock data generator
- Keyboard event tester
- ASCII table