-
Notifications
You must be signed in to change notification settings - Fork 0
Home
PotatoScript edited this page May 5, 2025
·
2 revisions
curl (short for Client URL) is a command-line tool used to send and receive data to/from servers over various protocols, most commonly HTTP or HTTPS.
curl lets you test or interact with web APIs or websites from the terminal.
| Task | Example Command |
|---|---|
| π Get a webpage or API data | curl https://example.com |
| π€ Send JSON data to an API | curl -X POST -H "Content-Type: application/json" -d '{"name":"Lucy"}' https://api.example.com |
| π Download a file | curl -O https://example.com/file.pdf |
| π¬ Send form data | curl -d "username=admin&password=1234" https://example.com/login |
To test your own local Japanese vocabulary app backend:
curl http://localhost:5000/api/vocabIt will return all vocab entries in your database (like a test client calling your API).
curl --versionIf it's not installed:
-
Ubuntu:
sudo apt install curl - Windows (WSL): Should be preinstalled
- Windows CMD/Powershell: Also supported natively in recent versions
curl https://jsonplaceholder.typicode.com/postsThis fetches data from a fake REST API.
Tip: Use | less to scroll the result
curl https://jsonplaceholder.typicode.com/posts | lesscurl https://example.com -o example.htmlcurl -X POST https://jsonplaceholder.typicode.com/posts \
-H "Content-Type: application/json" \
-d '{"title":"Hello","body":"World","userId":1}'curl -X POST -d "username=admin&password=1234" https://example.com/logincurl -H "Authorization: Bearer YOUR_TOKEN" https://api.example.com/datacurl -L https://bit.ly/3URLcurl http://localhost:5000/api/itemsTo test POST:
curl -X POST http://localhost:5000/api/items \
-H "Content-Type: application/json" \
-d '{"name":"Potato"}'-
-Iβ Only show HTTP headers:curl -I https://example.com -
-uβ Basic auth:curl -u username:password https://example.com -
-vβ Verbose/debug:curl -v https://example.com
curl https://example.comcurl -X POST -d "username=lucy&password=1234" https://example.com/logincurl -X POST -H "Content-Type: application/json" \
-d '{"word": "ζγ", "meaning": "to challenge"}' \
https://api.example.com/vocabcurl -H "Authorization: Bearer YOUR_TOKEN" https://api.example.com/datacurl -F "file=@path/to/file.jpg" https://example.com/uploadcurl -o output.html https://example.comcurl -L https://example.comcurl -v https://example.comcurl -I https://example.comcurl -u username:password https://example.comcurl http://localhost:8000/api/items