API Request Generator & Tester
12 languages
:
const response = await fetch('https://api.example.com/endpoint', {
  method: 'GET',
});

const data = await response.json();
console.log(data);
Fetch
🔖
Bookmark this page
Press Ctrl+D to save this tool in your browser for instant access anytime — no sign-up needed.

API Request Generator & Tester — HTTP Code in 12 Languages with GraphQL & Tests

Share

About this tool

Generate API Code in 12 Languages — and Test APIs Live in the Browser

Every developer who works with APIs runs into the same problem: you know what request you need to make, but translating that into the correct syntax for your language takes time. A fetch call in JavaScript looks nothing like a requests.get() in Python, and both look nothing like the cURL command you paste into your terminal or the net/http code your Go colleague needs. You end up context-switching between documentation pages just to write boilerplate.

This API Request Generator & Tester solves that. Configure your request once — method, URL, query params, headers, body, and auth — and get production-ready code for 12 outputs simultaneously: Fetch, Axios, XMLHttpRequest, Node.js native fetch, cURL, Python requests, PHP cURL, Ruby net/http, Go net/http, C# HttpClient, Jest tests, and Pytest tests.

Live API testing is built directly into the tool. Click the Send button (or press Ctrl+Enter) to fire the request from your browser and see the real response immediately. The Response panel shows the HTTP status code, response time in milliseconds, body size, and a syntax-highlighted JSON viewer with line numbers. Response headers are displayed below the body in a scrollable table. If the API blocks browser requests due to CORS, a "Retry with CORS Proxy" button re-routes the request through a proxy automatically.

Environment variables let you define {{API_KEY}}, {{BASE_URL}}, or any other placeholder and swap values between dev, staging, and prod environments without editing your request configuration. Switch environments in the Env tab and every {{VAR}} in your URL, headers, and body is substituted automatically before code is generated.

Request history saves every request you send or copy to localStorage so you can recall any past configuration instantly. Click History to see your recent requests and restore any of them with a single click.

Postman and Insomnia import reads your .json collection files locally in the browser (never uploaded). Import a Postman Collection v2.1 or Insomnia v4 export and all request fields — method, URL, headers, body, auth, even GraphQL queries — are loaded automatically.

GraphQL support is built into the Body tab. Select the GraphQL body type to get a dedicated query editor and variables JSON editor. The tool serializes these into the standard {"query": "...", "variables": {...}} JSON format and generates correct POST requests for all 12 language outputs.

Test generation in Jest and Pytest tabs produces ready-to-run test boilerplate with happy-path and error-path test cases pre-populated with your request configuration.

Everything runs in your browser. Your request goes directly to the target API — no data ever touches the tool's servers. Your tokens, passwords, and API keys stay on your device.

Features

  • Live API testing — Send button fires real requests from the browser; response panel shows status, time, size, syntax-highlighted JSON body, and headers
  • 12 language outputs — Fetch, Axios, XHR, Node.js (18+), cURL, Python requests, PHP cURL, Ruby net/http, Go net/http, C# HttpClient, Jest tests, Pytest tests
  • CORS proxy — one-click retry via corsproxy.io when the browser blocks a request due to CORS policy
  • GraphQL support — dedicated query + variables editor in the Body tab; serialized to standard HTTP POST format for all languages
  • Environment variables — define {{VAR}} placeholders, create dev/staging/prod environments, swap values without touching the request
  • Request history — auto-saved to localStorage on Send or Copy; restore any past request with one click from the History panel
  • Postman/Insomnia import — read .json collection files locally; supports Postman Collection v2.1 and Insomnia v4 export format
  • 7 HTTP methods — GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS with color-coded method badge
  • 5 body types — JSON, form-data, url-encoded, raw, GraphQL with syntax-aware formatting
  • 4 auth types — None, Bearer Token, Basic Auth (auto base64-encoded), API Key (header or query param)
  • Live code generation — code updates instantly as you type with no Generate button needed

How to Use

  1. 1
    Select your HTTP method and enter the URLClick the method dropdown and select GET, POST, PUT, PATCH, DELETE, HEAD, or OPTIONS. Paste your endpoint URL into the URL bar. For GET and HEAD, the body is automatically disabled. Use {{BASE_URL}} in the URL field if you plan to swap it across environments.
  2. 2
    Add query params and headersOpen the Params tab to add query string parameters as key-value pairs with per-row enable/disable checkboxes. Open Headers to add custom request headers. Common headers like Content-Type are injected automatically based on your body type.
  3. 3
    Configure the request body or GraphQL queryOpen the Body tab. For REST APIs, select JSON and type your payload. For GraphQL APIs, select GraphQL to get a dedicated query editor and variables JSON field. For file uploads use Form Data, for HTML forms use URL Encoded, for XML or other formats use Raw.
  4. 4
    Set up authenticationOpen the Auth tab. Choose Bearer Token and paste a JWT, Basic Auth with username and password (base64 encoded automatically), or API Key with the key name and value placed in a header or query parameter.
  5. 5
    Define environment variables (optional)Open the Env tab to add key-value variables for your current environment. Create multiple environments (dev, staging, prod) with the + button. Use {{VAR_NAME}} anywhere in your URL, headers, or body — the values are substituted when code is generated.
  6. 6
    Import from Postman or Insomnia (optional)Click Import in the toolbar and select a .json collection file. The request fields are loaded from the file. For multi-request collections, pick which request to load from the picker.
  7. 7
    Send the request or copy the generated codeClick Send (or press Ctrl+Enter) to fire the request live and see the response — status code, time, highlighted JSON body, and headers all appear in the Response panel. Switch to the Code tab at any time to copy the generated snippet in any language. The Jest and Pytest tabs generate test boilerplate ready to drop into your test suite.

Common Use Cases

🚀
Live API Testing
Click Send to fire real requests from the browser and inspect the response — status code, latency, body, and headers — without switching to a separate tool like Postman or Insomnia.
🔗
REST API Integration
Translate API documentation examples into your language instantly. Paste the endpoint URL and headers from the docs, select your language, and get copy-paste-ready code for your stack.
⚛️
GraphQL API Calls
Write your GraphQL query and variables in the dedicated editor. The tool generates the correct HTTP POST format for all 12 languages — no manual JSON serialization needed.
🌍
Multi-Environment Teams
Define {{API_KEY}} and {{BASE_URL}} once, create dev/staging/prod environments in the Env tab, and switch between them with one click. Every team member uses the same request config.
📦
Postman/Insomnia Migration
Import your existing Postman Collection v2.1 or Insomnia v4 exports and get code in 12 languages immediately, without reconfiguring headers, auth, or body from scratch.
🧪
Test Boilerplate Generation
Switch to the Jest or Pytest tab to get a ready-to-run test file with happy-path and error-path cases pre-populated with your request URL, headers, and body.
🎓
Learning HTTP Clients
See how the same request is expressed across languages. Compare JavaScript fetch vs Axios vs XMLHttpRequest side by side, or learn how Python requests maps query params to Go url.Values.

Frequently Asked Questions

The tool supports all standard HTTP methods: GET, POST, PUT, PATCH, DELETE, HEAD, and OPTIONS. For GET and HEAD requests, the body section is automatically disabled since these methods do not send a request body. Body fields are fully available for POST, PUT, PATCH, DELETE, and OPTIONS requests. The selected method is color-coded in the URL bar — green for GET, blue for POST, amber for PUT, purple for PATCH, and red for DELETE — for quick visual identification.

Four authentication types are supported. None — no auth headers are added. Bearer Token — your token is added as the Authorization: Bearer <token> header. Basic Auth — your username and password are base64-encoded and added as Authorization: Basic <base64(user:pass)>. API Key — your key name and value can be added either as a request header (for example X-API-Key: your-value) or as a query parameter appended to the URL. In all cases, the auth details are automatically included in the generated code for every language.

Five body formats are available. None sends no body. JSON — paste or type a JSON object and the tool generates JSON.stringify() in JavaScript, json= in Python, json_encode() in PHP, and the equivalent for all other languages. Form Data — key-value pairs encoded as multipart/form-data, used for file uploads and HTML form submissions. URL Encoded — key-value pairs encoded as application/x-www-form-urlencoded, the format used by standard HTML forms. Raw — any free-text body string, useful for XML, plain text, or custom formats. The Content-Type header is automatically set based on the body type selected.

The Fetch tab generates code for browser environments using the Fetch API available in modern browsers (Chrome 42+, Firefox 39+, Safari 10.1+). The Node.js tab generates code for server-side JavaScript using the native fetch API introduced in Node.js 18. The code is almost identical — both use async/await and return a Response object — but the Node.js version includes a comment indicating the minimum Node version. If you are targeting older Node.js versions (16 or below), you will need the node-fetch package (npm install node-fetch) and should add import fetch from "node-fetch" at the top.

Use the Params tab in the left panel. Each row has a checkbox (to enable or disable it), a key field, and a value field. Enabled params are automatically URL-encoded and appended to the URL as a query string in the generated code. You can also type the query string directly in the URL field — the tool will keep it as-is without double-encoding. For Python, the params are generated as a params={} dictionary for GET requests, which requests encodes automatically. For cURL, params are embedded directly in the URL.

The cURL tab generates a shell command using the curl CLI tool — this runs directly in a terminal and is useful for quick testing, documentation, and sharing. The PHP tab generates PHP code using the cURL library (libcurl), which is PHP's standard way to make HTTP requests. PHP cURL uses curl_init(), curl_setopt() to configure the request, and curl_exec() to run it. The options used in PHP cURL correspond to the flags used by the curl CLI. Both set the same headers, method, and body — they are just different interfaces to the same underlying libcurl library.

The generated Axios code uses the generic axios({ method, url, headers, data }) config object syntax, which works with Axios v0.x, v1.x, and the latest v1.7+. The code uses async/await syntax. For Axios v1.x, install with npm install axios. The generated code also uses the shorthand form (axios.get(), axios.post()) where appropriate. For browsers using Axios via CDN, replace the import statement with a <script> tag. For Next.js and React projects, Axios works in both client components and server-side code.

CORS (Cross-Origin Resource Sharing) errors occur when a browser blocks a request to a different origin because the server does not include the correct Access-Control-Allow-Origin header in its response. The generated Fetch and Axios code runs in the browser and will be subject to CORS. To fix it: (1) Add CORS headers on your API server — Access-Control-Allow-Origin: * or the specific origin. (2) Use the Node.js generated code to make the request server-side, where CORS does not apply. (3) Add a CORS proxy for development. The cURL, Python, PHP, Ruby, Go, and C# code all run server-side and are never subject to CORS.

It does both. Click the Send button in the URL bar (or press Ctrl+Enter) to fire the request live from your browser using the native Fetch API. The response panel shows the HTTP status code, response time in milliseconds, body size, syntax-highlighted JSON body with line numbers, and all response headers. This lets you test and debug APIs without leaving the tool. Code generation still works simultaneously — switch to the Code tab at any time to copy the generated snippet in any of the 12 supported languages. No data is ever sent to the tool's own servers — the request goes directly from your browser to the target API.

When you test an API that does not allow browser requests from other origins, the browser blocks the request with a CORS policy error. The tool detects this and shows a clear "CORS Blocked" message instead of a confusing network error. A "Retry with CORS Proxy" button appears — clicking it re-sends the request through corsproxy.io, which adds the necessary CORS headers so the response reaches your browser. A yellow banner is shown whenever the proxy is active, with a Disable button to turn it off. Important: do not use the CORS proxy with sensitive credentials or private data, since requests are routed through a third-party service.

The generated Go code is a complete main package file. Save it as main.go in a new directory, run go mod init example.com/request to initialize a module, then run go run main.go. The code uses only the Go standard library — no external dependencies are needed. For JSON requests, the body is embedded directly as a JSON byte slice using backtick string literals. For form-data requests, the code uses mime/multipart to construct the multipart body and automatically sets the Content-Type header with the correct boundary using mw.FormDataContentType().

The Env tab lets you define key-value variable pairs per environment (dev, staging, prod, etc.). Add a variable like API_KEY with its value, then use {{API_KEY}} anywhere in your URL, headers, or body. When you switch environments, all {{VAR}} placeholders in your request are automatically substituted with the values from the active environment before code is generated. This lets you maintain one request configuration and swap credentials between environments without editing any fields. Multiple environments can be created using the + button in the Env tab.

Click the Import button in the toolbar and select a JSON file exported from Postman (Collection v2.1 format) or Insomnia (v4 export format). The tool reads the file locally in your browser — it is never uploaded to any server. If the file contains a single request, it is loaded immediately. If it contains multiple requests (a collection), a picker modal appears so you can select which request to import. After import, the method, URL, query params, headers, body, auth, and GraphQL query are all populated from the file.

Select GraphQL in the Body tab to get a two-field editor: a Query textarea for your GraphQL query string and a Variables textarea for a JSON variables object. The tool serializes these into the standard GraphQL HTTP request format: a POST with Content-Type: application/json and a JSON body containing {"query": "...", "variables": {...}}. This works with any GraphQL API endpoint including Apollo Server, Hasura, and GitHub GraphQL API. All 12 language outputs (Fetch, Axios, Python, Go, etc.) correctly generate the serialized GraphQL body.

The Jest tab generates a JavaScript test file using Axios and Jest — a describe block with two test cases: one that asserts status 200 and a defined response, and one that tests error handling with an invalid auth token. The Pytest tab generates a Python test class using requests and pytest with the same two test cases. Both generators use your current request configuration — URL, headers, body, and auth — so the boilerplate is ready to run. Commented-out example assertions are included as a starting point for more specific response shape checks.

Click the cURL tab in the language tab bar on the right panel. The cURL command is generated instantly and includes all headers, body, and auth exactly as configured. Click ⎘ Copy to copy it to your clipboard. The cURL command is also useful for sharing a request in bug reports, API documentation, and Stack Overflow questions.