Master HTTPie: A Simpler, Colorful Alternative to cURL for Fast API Calls
This article introduces HTTPie, a Python‑based command‑line HTTP client that offers a simpler syntax, colored output, JSON support, and cross‑platform installation options, and provides detailed usage examples and tips compared with the traditional cURL tool.
httpie
httpie is a Python‑written HTTP command‑line client that runs on Windows, Linux and macOS. It is easy to learn—most users can start using it within five minutes. Its main features include:
Simple syntax
Formatted, colored output
Supports Windows, Linux and macOS
Handles both HTTP and HTTPS
File upload support
Persistent sessions
Built‑in JSON handling and Wget‑style downloads
Plugin system
VS cURL
Compared with cURL, httpie provides a more human‑readable syntax and clearer request parameters.
Installation
PyPI
Works on any platform with Python 3.7+.
# install
pip install httpieWindows
Install via Chocolatey.
# install
choco install httpie
# upgrade
choco upgrade httpiemacOS
Install with Homebrew.
brew update
# install
brew install httpie
# upgrade
brew upgrade httpieLinux
Debian/Ubuntu:
apt update
# install
apt install httpie
# upgrade
apt upgrade httpieRed Hat/CentOS:
yum install epel-release
# install
yum install httpie
# upgrade
yum upgrade httpieFedora (if preferred):
dnf install httpieUsage
The basic command format is: https|http [flags] [METHOD] URL [ITEM [ITEM]] Run http --help for detailed options.
Request Method
The method is optional; httpie infers it automatically. Explicitly specifying a method overrides the inference.
http pie.dev/get http POST pie.dev/getQuery String Parameters
Use == for query parameters and = for request‑body fields, eliminating the need for URL‑encoding.
http https://api.github.com/search/repositories q==httpie per_page==1File‑Based Parameters
Reference external files with @ to supply headers, query values, or JSON bodies.
http POST pie.dev/post \
Authentication:@files/jwt.txt # header from file
token==@files/text.txt # query from file
name=@files/text.txt # body from file
bookmarks:=@files/data.json # embed JSON fileJSON Support
Use --json or -j to set Accept: application/json automatically; key‑value pairs become JSON fields. http -j PUT pie.dev/put name=felord age=18 Without -j, raw JSON values are expressed with := and files with @:
http PUT pie.dev/put \
name=John \
age:=29 \
married:=false \
hobbies:=['"http"','"pies"'] \
favorite:={"tool":"HTTPie"} \
bookmarks:=@files/data.json \
description=@files/text.txtThe resulting request body is:
{
"name": "John",
"age": 29,
"married": false,
"hobbies": ["http", "pies"],
"favorite": {"tool": "HTTPie"},
"bookmarks": {"httpie": {"says": "Hello, World!"}},
"description": "Hello, World!
"
}Nested Structures
Nested JSON can be expressed directly using the same syntax.
Tips and Shortcuts
Quick request syntax:
# https://baidu.com
https ://baidu.comFor localhost, omit the scheme:
# https://localhost:8080/yourapi
https :8080/yourapiFile upload/download examples:
http POST example.com/upload < ~/upload.pdf
http GET example.com/download.pdf > ~/download.pdf
# form upload
http -f POST example.com/form-with-file myUpload@~/example.pdfAdditional Note
httpie also offers a UI client currently in beta testing, not yet publicly available.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
