Skip to content

API Request Builder

Build an HTTP request with query parameters, headers, auth and a body. Send it from your browser to see the response, or copy it as cURL, JavaScript fetch or raw HTTP.


  
Response

    

Last reviewed:

What is an API request builder?

Every call to a web API is an HTTP request with the same few parts: a method (GET, POST, PUT, PATCH, DELETE and so on), a URL with an optional query string, a set of headers, and for methods that send data, a body. Authentication usually travels in a header, for example Authorization: Bearer <token> or a vendor-specific key like X-API-Key. The body needs a Content-Type header that tells the server how to read it, most often application/json or application/x-www-form-urlencoded.

Getting those details right by hand is fiddly. Query values must be percent-encoded, Basic credentials must be Base64-encoded, quotes in a JSON body must be escaped for the shell, and every language writes the same request differently. A request builder lets you fill in the parts in a form and produces correct code for you: a curl command for terminals and documentation, a JavaScript fetch call for front-end or Node.js code, and the raw HTTP message as it travels over the wire.

This builder can also send the request from your browser. That is convenient for public APIs, but browsers enforce CORS (Cross-Origin Resource Sharing): a page on one site can only read a response from another site if that server explicitly allows it. Many APIs do not, so the builder always gives you a cURL command that works from any terminal without CORS.

How to use this tool

  1. Choose the method and type the full URL, including https://. If you paste a URL with a query string, the parameters move into the Params tab when you leave the field or press Enter.
  2. In Params, add query parameters as name and value pairs. Values are percent-encoded for you. Untick a row to leave it out without deleting it; the tab shows how many are active.
  3. In Headers, add or edit headers. An Accept: application/json row is there to start with.
  4. In Auth, choose Bearer token, Basic auth (username and password, Base64-encoded for you) or API key header (header name defaults to X-API-Key). The resulting header is added to the request.
  5. In Body, choose JSON, Form (one key=value per line, sent URL-encoded) or Text. A matching Content-Type is added unless you set one yourself. JSON is checked before anything is generated. Bodies are ignored for GET and HEAD.
  6. Switch between cURL, fetch and HTTP to see the generated code, and click Copy.
  7. Click Send (or press Enter in the URL field) to send the request. The response panel shows the status, time, size, response headers and the body, with JSON pretty-printed. Requests time out after 30 seconds.

Examples

GET with query parameters and a bearer token

Method GET, URL https://api.github.com/repos/nodejs/node/issues, params state=open, labels=good first issue, per_page=5, bearer token ghp_exampletoken123 (not a real token). The cURL tab shows:

curl 'https://api.github.com/repos/nodejs/node/issues?state=open&labels=good+first+issue&per_page=5' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer ghp_exampletoken123'

The spaces in good first issue are encoded as +, the form used in query strings.

POST JSON with Basic auth

Username ada, password s3cret, JSON body {"sku":"TSHIRT-M","qty":2,"note":"It's a gift"}:

curl -X POST 'https://api.example.com/v1/orders' \
  -H 'Accept: application/json' \
  -H 'Authorization: Basic YWRhOnMzY3JldA==' \
  -H 'Content-Type: application/json' \
  --data-raw '{"sku":"TSHIRT-M","qty":2,"note":"It'\''s a gift"}'

YWRhOnMzY3JldA== is the Base64 encoding of ada:s3cret, and the apostrophe is escaped so the command works in bash and zsh. The fetch tab writes the body as an object:

const res = await fetch('https://api.example.com/v1/orders', {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Authorization': 'Basic YWRhOnMzY3JldA==',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "sku": "TSHIRT-M",
    "qty": 2,
    "note": "It's a gift"
  }),
});
const data = await res.json();

OAuth token request as a form

Body type Form with three lines, grant_type=client_credentials, scope=read:orders write:orders and client_id=my-app. The HTTP tab shows the raw message:

POST /oauth/token HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 81

grant_type=client_credentials&scope=read%3Aorders+write%3Aorders&client_id=my-app

Common errors and how to fix them

  • "Enter a full URL starting with http:// or https://". The URL has no scheme, as in api.example.com/users. Add https://.
  • "Only http and https URLs are supported." Other schemes, such as ftp:// or ws://, cannot be sent with fetch.
  • "The JSON body is not valid". The body must be strict JSON: double-quoted keys and strings, no trailing commas, no comments. {'a':1} fails with "Expected property name or '}' in JSON at position 1".
  • "The browser could not complete the request." This is almost always CORS: the API does not return an Access-Control-Allow-Origin header for this site. It can also be a DNS failure, an invalid certificate, or an http:// URL blocked as mixed content on this HTTPS page. Copy the cURL command and run it in a terminal, where CORS does not apply.
  • 401 Unauthorized. The token is missing, expired or sent in the wrong format. Check whether the API wants Bearer, a custom header, or a query parameter, and look at the token's exp claim if it is a JWT.
  • 415 Unsupported Media Type or 400 Bad Request on POST. The server expected a different body format. Match the Content-Type and body type to what the API documents.
  • A header you set has no effect. Browsers do not let scripts set some headers, including Host, Cookie, Origin, Referer and Content-Length. They still appear in the generated cURL, which sends them.

When developers use this

  • Trying a third-party API from its documentation before writing integration code.
  • Turning a request into a cURL command to attach to a bug report or share with a teammate.
  • Getting a correctly escaped fetch call to paste into front-end or Node.js code.
  • Checking what a request looks like on the wire, including the computed Content-Length and Basic auth header.
  • Reproducing a failing call from a log with the same method, headers and body to see the exact status and response.
  • Testing a CORS configuration: if Send works here, the API allows browser calls from other origins.

Privacy and how it works

The code snippets are generated in your browser and nothing you type is stored or sent to DevToolWorld. When you click Send, your browser makes the request directly to the URL you entered, including the headers, token and body. It does not pass through a DevToolWorld server, so only you and the API see it. Treat tokens with normal care: avoid sending production credentials to endpoints you do not trust, and remember that a copied cURL command contains the secret in plain text.

Limitations

  • Sending is subject to CORS, so many APIs only work through the copied cURL command.
  • Cookies stored for the API's site are not sent with the request, and file uploads (multipart forms) are not supported.
  • Some response headers are hidden from browser scripts unless the server lists them in Access-Control-Expose-Headers, so the response panel may show fewer headers than cURL.

FAQ

Why does Send fail when the same request works in cURL?

Browsers apply CORS; cURL does not. The API must answer with an Access-Control-Allow-Origin header that allows this site, and for requests with JSON bodies or an Authorization header it must also answer a preflight OPTIONS request. Many server-to-server APIs never do, by design.

Is my API token sent to DevToolWorld?

No. Requests go directly from your browser to the API you specify, and the code is generated locally. Nothing is logged or saved, and the token disappears when you close the tab.

Does the cURL command work on Windows?

It is written for bash and zsh with single quotes and \ line continuations, so it works in WSL, Git Bash and macOS or Linux terminals. In PowerShell or cmd.exe, quoting rules differ; join the lines and use curl.exe with double quotes, escaping any inner double quotes.

Can I send a body with a GET request?

Not here. The body is ignored for GET and HEAD, because the HTTP specification gives a body in a GET no defined meaning and fetch refuses to send one. Put the data in query parameters or use POST.

Why are spaces in my parameters shown as +?

Query strings use the application/x-www-form-urlencoded rules, where a space is written as + and characters such as : become %3A. Servers decode them back to the original values.

What is the difference between the Auth tab and adding a header myself?

They produce the same result. The Auth tab saves you from Base64-encoding Basic credentials or typing the Bearer prefix, and keeps the secret out of the headers list while you work.

Can I call an API running on localhost?

Often yes. Chrome, Edge and Firefox treat http://localhost as a secure destination, so it is not blocked as mixed content. Your local server still has to allow CORS from this site, and newer browser versions may also ask for permission to access the local network. If it fails, use the cURL command.

Guides