<- back

# CURL and how to use it

Posted on Jan 17, 2026

CURL stands for Client URL Request Library, it allows us to send and receive data from the command line. It can be used for transferring data between servers and has support for many protocols such as: HTTP, HTTPS, FTP, etc.

The basic structure of a CURL command is: curl [options] [URL]

Example:

curl https://example.com/ 
curl -X POST https://example.com/api/resource/ 

## Commonly Used Flags

Flag Desc. Syntax
-O Download the file and save it under its original name
curl -O [URL]
-o Download the file and save it with a different name
curl -o [filename] [URL]
-X Allows us to specify HTTP method
curl -X PUT/GET/etc. [URL]
-I Only fetch headers
curl -I [URL]
-d Implies POST, used to send data
curl -d "name=JoeMama" [URL]
-L Follow redirect
curl -L [URL]
--limit-rate [speed] Allows us to throttle download speed
curl --limit-rate 100k -O [URL]
-c Download the cookies to a file
curl -c cookies.txt [URL]
-i Include response headers in output
curl -i [URL]

## Common Use Cases

POST JSON

curl -H "Content-Type: application/json" -d '{"id":1001}' [URL]

Custom methods

curl -X PUT URL
curl -X PATCH URL
curl -X DELETE URL

## Basic Authentication

Inline passing username and password:

curl -u user:pass [URL]

Prompt for password in terminal (safer):

curl -u user [URL]

Pass API key in query string

curl "https://api.example.com/me?api_key=$API_KEY"

## References: