curl GET request: parameters, response headers and status code
Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. Download, no sign-up →
GET is the simplest request: curl and a URL. Trouble starts with parameters containing spaces and non-Latin text, with redirects, and with seeing the status code and headers. Below are working commands for each case.
Query parameters
Short parameters can go straight in the URL, but quote the URL: an ampersand in the shell means run in background. If values contain spaces, non-Latin text or special characters, use -G with --data-urlencode: curl encodes the values and appends them.
Response headers and status code
By default curl prints only the body. -i adds the status line and response headers, -I sends HEAD and shows only headers, and -w with the http_code variable prints the code, handy in scripts and health checks.

Redirects
curl does not follow redirects by itself: on a 301 or 302 you see an empty or short body. Add -L. If auth disappears after a redirect, that is protection: curl does not send credentials to another host without --location-trusted.
GET commands
# простой GET, адрес в кавычках из-за &
curl "https://api.example.com/v1/orders?status=new&limit=10"
# параметры с пробелами и кириллицей: curl закодирует сам
curl -G https://api.example.com/v1/search \
--data-urlencode "q=монитор 24 дюйма" \
--data-urlencode "city=Москва"
# заголовки ответа вместе с телом
curl -i https://api.example.com/v1/orders/5001
# только заголовки (HEAD)
curl -I https://api.example.com/v1/orders/5001
# только код ответа
curl -s -o /dev/null -w "%{http_code}\n" https://api.example.com/health
# пройти редиректы
curl -L https://example.com/old-path
Which flag shows what
| Flag | What it does |
|---|---|
| -i | Status and response headers with the body |
| -I | HEAD request, headers only |
| -G --data-urlencode | Build and encode URL parameters |
| -w "%{http_code}" | Print the status code |
| -L | Follow redirects |
| -s | No progress meter |
A 200 does not mean the answer is right: it may hold an empty array or someone else's data. See HTTP response checks.
More on curl
Section overview and all guides: curl command cheat sheet: flags and examples for APIs.
- cURL examples: GET and POST requests with JSON on Linux, Windows and PowerShell
- Headers in curl: Content-Type application/json, Accept and multiple -H
- curl with authorization: Bearer token, Basic, API key and headers
- curl errors: codes 6, 7, 22, 28, 35, 60 and how to fix them
- curl on Windows and PowerShell: how to run it and why commands fail
Frequently asked questions
How do I send a GET with parameters?
Put them in a quoted URL or use -G with --data-urlencode.
How do I see response headers?
-i shows headers with the body, -I sends HEAD and shows only headers.
How do I print only the status code?
curl -s -o /dev/null -w "%{http_code}" URL; on Windows use NUL instead of /dev/null.
Repeat this on your own API
Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.
Download FreeDownload and first runNo sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.
References
Start with the linked example and compare its result with your own test requirement.