cURL: send requests from the command line

cURL is a command-line tool and library for transferring data through URLs. It is useful for testing APIs, downloading files, and checking server responses.

What you will learn

Make a GET request

curl https://example.com/api/tasks

cURL prints the response body. Add -i when you also want to inspect response headers, or -I to request headers only.

Send a POST body

curl -X POST https://example.com/form-submit \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data "age=30&name=Yugien"

-X selects a method, -H adds a header, and --data sends the request body. Use the exact content type and format expected by the API.

Client checks are not security

A browser form may say that an age must be between 0 and 120, but another client can send age=9999. Validate type, range, permissions, and business rules on the server before saving or acting on data.

Common mistakes