C.W.K.
Stream
Lesson 06 of 08 · published

HTTPie — Friendlier HTTP

~8 min · httpie, http, alternative

Level 0Window Tourist
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

What HTTPie is for

curl is unbeatable for scripting. HTTPie is what you reach for when you're exploring an API by hand: shorter syntax, JSON-aware, syntax-highlighted output. brew install httpie.

Sane defaults

http https://api.github.com/users/cli
# Same as: curl -sS -H 'Accept: application/json' https://...

HTTPie defaults to JSON-friendly Accept header, follows redirects less aggressively, prints colored JSON. The output reads like documentation.

POST in 30 seconds

http POST https://api.example/items name=pippa qty:=3 active:=true

Reads as: "POST to that URL, with JSON body {name: 'pippa', qty: 3, active: true}." The := is for non-string values (numbers, booleans). Plain = is string. No need to quote the JSON yourself.

Headers, auth, files

  • http GET https://... 'Authorization: Bearer xyz'
  • http -a user:pass GET https://...
  • http POST https://... < body.json — body from a file via stdin.
  • http --download https://.../file.zip — progress bar, filename auto-detect.

Sessions

http --session=mysession POST https://api/login user=alice pass=... saves cookies, headers, and base auth. Subsequent http --session=mysession ... calls reuse them. Useful for multi-step API explorations.

When curl still wins

Scripts that have to run on minimal containers (no Python). Performance-critical loops. Tools that already use curl. For everything else — especially when you're at a prompt — HTTPie is the friendly default.

Code

Side by side·bash
# curl version
curl -sS -X POST https://httpbin.org/post \
  -H 'Content-Type: application/json' \
  -d '{"name":"pippa","qty":3}'
# httpie version
http POST https://httpbin.org/post name=pippa qty:=3

External links

Exercise

Install httpie: brew install httpie. Run http GET https://api.github.com/users/cli. Then http POST https://httpbin.org/post name=pippa qty:=3 active:=true and read the JSON echo.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.