Curl Examples

49 curl commands for the requests people actually make, each with the flags explained, the mistakes that go with it, and where it helps, a button to run it.

Last updated . How this page is checked.

Curl is the common language of HTTP APIs: documentation is written in it, bug reports quote it, and support teams ask for it. A curl command is a complete, unambiguous description of a request, which is exactly why a small misunderstanding of one flag produces confusing results. These pages take one task at a time and show the command, what each part contributes, and what the server sees.

Runnable examples point at httpbin.org, a public service that echoes back whatever you send, so you can see the effect of a flag in the response. If you would rather not use a terminal, the API Tester sends the same requests from your browser, and the curl converter turns any command into Python, JavaScript, PHP and more.

Curl commands at a glance

TaskCommand
GET Requestcurl https://httpbin.org/get
POST JSONcurl https://httpbin.org/post -H "Content-Type: application/json" -d '{"name":"Ada","role":"admin"}'
POST Formcurl -d "email=ada@example.com" -d "plan=starter" https://httpbin.org/post
POST Filecurl -F "file=@report.pdf" https://httpbin.org/post
Send Headercurl https://httpbin.org/headers -H "X-Request-Id: 7f3a9c" -H "Accept-Language: en-GB"
Bearer Token Auth Headercurl -H "Authorization: Bearer $TOKEN" https://httpbin.org/bearer
Basic Authcurl -u ada:s3cret https://httpbin.org/basic-auth/ada/s3cret
Follow Redirectcurl -L https://httpbin.org/redirect/2
Download Filecurl -fLO https://example.com/files/report.pdf
HEAD Requestcurl -I https://httpbin.org/get
Timeoutcurl --connect-timeout 5 --max-time 20 https://httpbin.org/delay/3
Proxy Servercurl -x http://proxy.example.com:8080 https://httpbin.org/ip

Methods

Request bodies

Headers

Authentication

HTTPS and TLS

Network behaviour

Reference

Converting curl

Reading a curl command

Everything after the word curl is either a flag or the URL, in any order. Flags come in a short form with one dash (-H) and a long form with two (--header); they are the same option. Some take a value, which follows the flag. A trailing backslash continues the command on the next line, purely for readability.

Three habits prevent most problems. Quote the URL and every header, because shells give meaning to &, ?, $ and spaces. Add -i when a result surprises you, since curl hides the status code by default. And when two requests that should be identical behave differently, compare them with -v rather than by reading the commands. How to use curl walks through this from the beginning, and the flags reference lists the options worth knowing.

Official curl documentation

  • curl project site — Downloads, release notes and the official documentation.
  • curl man page — The complete reference for every command-line option.
  • curl tutorial — The project's own introduction to using the tool.
  • 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.

Curl examples FAQ

What is a curl command?

A line you run in a terminal that tells the curl program to make a network request. It consists of the word curl, optional flags that shape the request, and a URL.

What are the most useful curl commands?

A plain GET (curl URL), a GET showing headers (curl -i URL), a JSON POST (curl -H "Content-Type: application/json" -d '{...}' URL), an authenticated request (curl -H "Authorization: Bearer TOKEN" URL) and a download (curl -LO URL).

Why do API docs use curl for examples?

Because curl is installed almost everywhere, works the same on every platform, and expresses a complete HTTP request in one copyable line that is easy to translate into any programming language.

Can I run these curl examples without installing anything?

Curl is included with macOS, most Linux distributions and Windows 10 and 11. Examples marked with a Run button can also be sent from the browser through the API Tester on this site.