Skip to content
CheckcraftDownload
Practical workflow

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.

Checkcraft ·

Get help with your first test →

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.

API call diagram: method and URL, headers, body, status and response body, logs and database

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
Layers of an API call check: status, headers, body, calculations, logs, database

Which flag shows what

FlagWhat it does
-iStatus and response headers with the body
-IHEAD request, headers only
-G --data-urlencodeBuild and encode URL parameters
-w "%{http_code}"Print the status code
-LFollow redirects
-sNo 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.

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.

Next step

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 run

No sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.

References

curl man page

Start with the linked example and compare its result with your own test requirement.

Ask a person

Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

No account required. We will reply by email. This is a support request, not a newsletter subscription.