Как установить HTTPie CLI: GET/POST, заголовки, JSON и сравнение с curl

Поставить http, отправить GET/POST с JSON, сопоставить с curl.

curl умеет всё, но флагов много. HTTPie (http) проще для GET/POST, заголовков и JSON. Материал:, but flags pile up fast. HTTPie (the http command) uses readable syntax for GET/POST, headers, and JSON bodies, with pretty-printed responses by default. установка macOS/Linux/Windows, GET/POST, заголовки, JSON, сравнение с curl для читателей hereink.

The query is how to install HTTPie CLI and send GET POST JSON requests. You should finish with http installed, a first GET to a public endpoint, a JSON POST, and the curl equivalents in mind.

installbrew · pip · apt
requestsGET · POST · JSON
comparehttp vs curl

Что решает HTTPie

Readable CLI HTTP

http GET api.example.com/users separates method, URL, and options; JSON responses are colorized and indented without juggling -H and -d order.

Pairs with jq

Pipe http GET … | jq '.data' to keep only the fields you need. Our jq guide covers transforms; HTTPie covers sending the request.

Upstream: github.com/httpie/cli, docs at httpie.io/docs/cli. Run http --version after install.

Установка HTTPie

  1. 1
    macOS (Homebrew)

    brew install httpie. Verify with which http and http --version.

  2. 2
    Linux (packages or pip)

    Debian/Ubuntu: sudo apt update && sudo apt install httpie. Fedora: sudo dnf install httpie. Generic: python3 -m pip install --user httpie; ensure ~/.local/bin is on PATH.

  3. 3
    Windows

    winget install httpie.httpie or pip install httpie. Open a new terminal and run http --version.

  4. 4
    First GET

    http GET https://httpbin.org/get should return JSON mirroring your request headers.

GET и query-параметры

http GET https://httpbin.org/get
http GET https://httpbin.org/get page==2 limit==10
http --body GET https://httpbin.org/uuid
http --follow GET https://httpbin.org/redirect/1

Omitting the method defaults to GET. For raw downloads or low-level HTTP, curl still wins; for JSON APIs, start with http.

POST и JSON-тело

http POST https://httpbin.org/post name=Ada role=admin
http POST https://httpbin.org/post tags:='["go","rust"]'
http POST https://httpbin.org/post < payload.json
http --form POST https://httpbin.org/post email=test@example.com

= sends string fields; := sends JSON literals. Test against httpbin or staging before hitting production.

Свои заголовки

http GET https://httpbin.org/headers Authorization:"Bearer YOUR_TOKEN" Accept:application/json
http GET api.example.com/v1/me X-Api-Key:xxx User-Agent:my-cli/1.0
http --download GET https://example.com/file.zip

HTTPie vs curl

GoalHTTPiecurl
GET JSONhttp GET https://httpbin.org/getcurl -s https://httpbin.org/get | jq .
Query stringhttp GET url q==searchcurl -s 'url?q=search'
POST JSONhttp POST url name=Adacurl -s -X POST -H 'Content-Type: application/json' -d '{"name":"Ada"}' url
Headerhttp GET url Authorization:"Bearer x"curl -s -H 'Authorization: Bearer x' url
Body onlyhttp --body GET urlcurl -s url
Multiparthttp --form POST url file@./a.pngcurl -F file=@./a.png url
Подходит
Manual API exploration, copy-paste examples in READMEs, JSON debugging beside jq and ripgrep.
Не подходит
Complex OAuth device flows, client-cert TLS, or reproducing full browser cookie jars—use curl or a dedicated client.
http or httpie command?

Package name is often httpie; the binary is http (and https). Run http --help.

Script-friendly output?

Use --body or --print=b, then pipe to jq. Add --check-status when exit codes must reflect HTTP status (see docs).

Replace curl entirely?

Use HTTPie for daily JSON REST; keep curl for legacy scripts, health checks, and edge protocols. Both on PATH is fine.

После API — сверить на одном листе

Once endpoints make sense in the terminal, service boundaries still belong on a shared canvas. See как создать пространство.

Начать