xh — Modern HTTP Client
Linux / Modern CLI Tools / xh.html
💬 "xh command"
xh is a friendly HTTP command-line client that replaces curl. Without complex flags, xh example.com shows JSON, headers, and status codes in a readable form right away.
Written in Rust, it follows the HTTPie command style while being faster and lighter. It handles redirects, JSON/form posts, auth, and downloads with concise options.
- Concept: Send HTTP requests from the terminal and print responses in a readable form.
- Features: JSON/form posts, auth, header setting, redirect following, and file downloads.
- Strength: Call APIs and inspect results with short commands instead of memorizing curl flags.
- Use when: Checking REST APIs, inspecting web responses, or testing authentication.
Basic Usage
xh defaults to GET, and passing key=value pairs sends JSON automatically.
1. Basic request
URL only sends a GET and prints the result nicely.
xh example.com
xh example.com/users/1 # inspect JSON response
2. Sending data
key=value turns into a JSON POST.
xh POST example.com/users name=John age:=30 email:=null
xh POST example.com login form==true username=admin password=secret
3. Auth, headers, download
Handle tokens, headers, and files easily.
xh example.com Authorization:"Bearer TOKEN"
xh --download example.com/file.zip
xh -v example.com # include headers
Installation & Download
xh installs via cargo, a package manager, or a release binary. It also provides http aliases.
| Environment | Command |
|---|---|
| cargo | cargo install xh |
| Ubuntu/Debian (if packaged) | sudo apt install xh |
| macOS (Homebrew) | brew install xh |
| Release binary | github.com/ducaale/xh/releases |
Verify with xh --version. To use the http and https aliases, create the symlinks suggested during install.
Common Options
| Command / Key | Description |
|---|---|
POST/PUT/PATCH | Choose the HTTP method |
key:=value | Send as a JSON type (number, array, null) |
key==value | Send as a URL query parameter |
--download | Save the response to a file |
-v | Show request and response headers in detail |
3 Essential Command Combinations
xh example.com/api/health— Check an API response at a glancexh POST api/login username=admin— Send a form/JSON login requestxh --download example.com/file.zip— Download a file
💬 "Using xh on a real server"
A step-by-step look at inspecting a local API.
Step 1 · Check service health
Check if the server is alive.
xh localhost:8080/health
Step 2 · Authenticated request
Call an auth endpoint with a token.
xh localhost:8080/api/me Authorization:"Bearer TOKEN"
Step 3 · Save the result
Store the response to a file.
xh localhost:8080/api/list --download resp.json
How it is used in practice
1. Health check
Situation — Verify service state after a deploy.
xh localhost:8080/health
Result — Status code and JSON body are visible at a glance.
Point — Check fast without memorizing curl flags.
2. Parameter testing
Situation — Test API with different query conditions.
xh 'example.com/api/items?limit==5&sort==desc'
Result — Attach queries easily with key==value.
Point — Try many combinations quickly to verify behavior.
Caveats
- Quote URLs containing
?and&with quotes to be safe. - The default allows URLs without a trailing slash, but writing the exact path is good practice.
- When using auth tokens they may land in shell history—consider temp files or env vars.