The command
curl https://httpbin.org/get
Opens the request console with this request filled in. It is sent from api-tester.com's server rather than from your machine, so it shows what the endpoint returns, not how your own network or curl build behaves.
What the flags do
| Flag | What it does |
|---|---|
-i | Print the response status line and headers before the body. |
-s | Silent: no progress meter. Pair with -S so errors still show. |
-G | Send any -d data as a query string instead of a body. |
-o file | Write the body to a file instead of the terminal. |
-w format | Print extra facts after the transfer, such as %{http_code}. |
Adding query parameters
You can type the query string straight into the URL, but then the escaping is your job: a space, an ampersand or a non-ASCII character in a value silently changes what the server receives. Let curl encode values instead. -G moves -d data into the URL, and --data-urlencode percent-encodes each value.
Always quote the URL. In most shells an unquoted & ends the command and runs the rest in the background, and ? can be treated as a filename wildcard.
curl -G https://httpbin.org/get \
--data-urlencode "q=rate limit & retries" \
--data-urlencode "page=2"
# same request, encoded by hand
curl "https://httpbin.org/get?q=rate%20limit%20%26%20retries&page=2"
Seeing more than the body
By default curl prints only the response body, which hides the two things you usually need when a request misbehaves: the status code and the headers. -i prints them above the body, -v adds the request curl sent, and -w extracts single values for scripts.
curl -i https://httpbin.org/get # headers + body
curl -s -o /dev/null -w "%{http_code}\n" https://httpbin.org/get # status only
curl -sS https://httpbin.org/get -o response.json # save, stay quiet
Common mistakes
- Do not add
-X GET. GET is already the default, and-Xalso overrides the method curl would pick after a redirect. - A GET with
-dbecomes a POST unless you also pass-G. - An HTTP error is not a curl error. A 404 still exits with code 0. Use
-fwhen a script needs a non-zero exit on 4xx and 5xx.
Related curl examples
Curl GET JSON Example
Fetching JSON is a GET with one header that says what you want back.
Curl Send Header Example
-H adds a header line to the request.
Curl HEAD Request Example
HEAD asks for the headers a GET would return and nothing else.
Curl Follow Redirect Example
Curl does not follow redirects unless asked.
Curl GET XML
Ask for XML instead of JSON and query the result.
All Curl Examples
49 worked examples, grouped by what you are trying to do.
More under Methods
References
- curl man page: -G — The flag that turns -d data into a query string.
- MDN: GET — What the method means and what a server may do with it.
These links leave api-tester.com, which is independent of the projects they point to.
FAQ
How do I send a GET request with curl?
Run curl followed by the URL, for example curl https://httpbin.org/get. GET is the default method, so no extra flag is needed.
How do I pass query parameters in a curl GET request?
Either put them in the quoted URL, or use -G with one --data-urlencode "name=value" per parameter so curl builds and percent-encodes the query string for you.
How do I see the response headers of a GET request?
Add -i to print the status line and headers above the body, or -v to also see the request curl sent.