The command
curl https://httpbin.org/get
Opens the request console with this request filled in. It is sent from api-tester.com's server rather than from your machine, so it shows what the endpoint returns, not how your own network or curl build behaves.
What the flags do
| Flag | What it does |
|---|---|
curl URL | GET the URL and print the response body. |
curl -i URL | Also print the status line and response headers. |
curl -v URL | Print the whole conversation, for debugging. |
curl -o file URL | Save the body to a file. |
curl -d data URL | POST data to the URL. |
Step 1: check it is there
Open a terminal and ask for the version. The first line is the version number; the lists below it are the protocols and features your build supports. If the command is not found, install the curl package with your system's package manager. On Windows 10 and 11 it is built in as curl.exe.
curl --version
Step 2: make a request and read it
The general shape is curl [options] URL. With no options curl sends a GET and writes the response body to the screen, nothing more. That is deliberate, so the output can be piped into other tools, but it hides the status code. Add -i and the first line of output tells you whether the request succeeded: 200 is success, 3xx a redirect, 4xx a problem with your request, 5xx a problem on the server.
curl https://httpbin.org/get
curl -i https://httpbin.org/status/404
Step 3: send something
Three additions cover most API calls. -H adds a header, such as an API key or the format you want back. -d adds a body, which turns the request into a POST. -X names a different method when you need PUT, PATCH or DELETE. Long commands are split across lines with a trailing backslash.
curl https://httpbin.org/post \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"name":"Ada"}'
curl -X DELETE https://httpbin.org/delete
Step 4: when it does not work
-v is the tool. Lines starting with * are curl describing what it is doing: resolving, connecting, negotiating TLS. Lines starting with > are the request it sent, and < the response headers it received. Nearly every problem shows up in one of those three places. If curl prints an error like curl: (6), the number is an exit code: 6 is a hostname that did not resolve, 7 a refused connection, 28 a timeout, 60 a certificate that failed verification.
curl -v https://httpbin.org/get
Common mistakes
- Quote your URLs. Characters such as
&and?mean something to the shell. - No output is not always failure. Redirects and
204responses have empty bodies. Check with-i. - Commands copied from documentation are usually written for bash. They need adjusting for Windows
cmdand PowerShell quoting.
Related curl examples
Curl Flags Example
Curl has well over two hundred options.
Curl GET Request Example
GET is what curl does when you give it nothing but a URL.
Curl POST JSON Example
Sending JSON takes two things: the JSON itself and a header saying that is what it is.
Curl for Windows Example
Windows has shipped a real curl since 2018.
All Curl Examples
49 worked examples, grouped by what you are trying to do.
More under Reference
References
- curl tutorial — The project's own walk-through, from a first request onwards.
- Everything curl — The free book by curl's maintainers, covering the tool end to end.
These links leave api-tester.com, which is independent of the projects they point to.
FAQ
What is curl used for?
Curl transfers data to or from a server from the command line. It is most often used to call and test HTTP APIs, download files and debug network requests.
How do I run a curl command?
Open a terminal, type curl followed by a URL and press Enter. Curl sends a GET request and prints the response body.
How do I check if curl is installed?
Run curl --version. If curl is installed it prints its version, supported protocols and features.