You’ve installed xh. Now let’s get you productive fast. This guide covers GET/POST/Header/Session/Download/curl translation — everything you need for daily API work.nn


nn

Basic Requests

nn

GET — the simplest start

nn

Bash
xh httpbin.org/getn

nnColored JSON back in milliseconds. No -X GET needed.nn

Auto-detected Method

nn

Bash
# Bare URL = GETnxh https://httpbin.org/jsonnn# With URL paramsnxh https://httpbin.org/get name==Tom page==1n

nn

POST with JSON Body

nn

Bash
xh post httpbin.org/post name=Tom age:=26n

nnNote the difference: name=Tom (string) vs age:=26 (:= forces JSON number type).nn

PUT / PATCH / DELETE

nn

Bash
xh put httpbin.org/put name=Updatednxh patch httpbin.org/patch name=Patchednxh delete httpbin.org/deleten

nn


nn

Headers and Query Parameters

nn

Custom Headers

nn

Bash
# Single headernxh httpbin.org/get user-agent:MyApp/1.0nn# Multiple headersnxh httpbin.org/get n  accept:application/json n  x-api-key:secret123n

nnHeader name followed by a colon :. Empty value? Just write content-type: with nothing after it.nn

URL Query Parameters (no more hand-written ? and &)

nn

Bash
# Instead of https://httpbin.org/get?page=2&sort=descnxh get httpbin.org/get page==2 sort==descn

nnThis alone makes xh worth using.nn


nn

Form Submissions and File Uploads

nn

Form Data (application/x-www-form-urlencoded)

nn

Bash
xh -f post httpbin.org/post username=admin password=123456n

nn-f is shorthand for --form.nn

Upload a File

nn

Bash
# @ reads file contentsnxh post httpbin.org/post document@report.pdfn

nn


nn

Sessions — Keep Login State

nn

Bash
# First: login (Session saves cookies)nxh post :8080/login username=admin password=secret --session=loginnn# Subsequent requests reuse the same sessionnxh get :8080/api/profile --session=loginn

nnIt’s like browser “remember me” — no manual cookie extraction.nn


nn

Downloads and Output Control

nn

Download to File

nn

Bash
xh -d https://httpbin.org/json -o response.jsonn

nn-d is --download, -o is --output.nn

Body-Only or Headers-Only

nn

Bash
# Body onlynxh httpbin.org/get -bnn# Headers onlynxh httpbin.org/get -hnn# Custom format (metadata + headers + body)nxh httpbin.org/get -p hmn# m = metadata, h = headers, b = bodyn

nn


nn

Most Useful: –curl Translation

nnTranslate any xh command to an equivalent curl command:nn

Bash
xh post httpbin.org/post name=Tom age:=26 --curln

nnOutputs:nn

Bash
curl -X POST https://httpbin.org/post n  -H "Content-Type: application/json" n  -d '{"Name":"Tom","age":26}'n

nnHandy for sharing with curl-only colleagues. Or construct without sending:nn

Bash
xh post :8080/api/users name=admin --offline --curlnnn

nn


nn

SSL and Timeout Control

nn

Skip SSL Verification (dev environments)

nn

Bash
xh https://expired-cert.example.com/get --verify=non

nn

Set a Timeout

nn

Bash
xh httpbin.org/delay/5 --timeout=3n

nn3-second timeout. Because waiting is boring.nn


nn

Quick Reference

nn

n n n

n

n

n

n

n n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

n

Scenario Command
GET xh url
POST JSON xh post url k=v
URL params xh url k==v
Header xh url name:value
Form xh -f post url k=v
Download xh -d url -o file
Session xh url --session=sess.txt
curl translate xh url --curl
Offline construct xh url --offline
Skip SSL xh url --verify=no

nn


nn

Next Steps

nnThat’s the full picture: intro, Linux install, macOS install, and usage guide — all published on the blog. Share the English version with international colleagues or Linux friends.nnQuestions? Comments welcome.

Last modified: 2026年7月6日

Author

Comments

Write a Reply or Comment

Your email address will not be published.