Operations 8 min read

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.

macrozheng
macrozheng
macrozheng
Master HTTPie: A Simpler, Colorful Alternative to cURL for Fast API Calls

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+.

<code># install
pip install httpie</code>

Windows

Install via Chocolatey.

<code># install
choco install httpie
# upgrade
choco upgrade httpie</code>

macOS

Install with Homebrew.

<code>brew update
# install
brew install httpie
# upgrade
brew upgrade httpie</code>

Linux

Debian/Ubuntu:

<code>apt update
# install
apt install httpie
# upgrade
apt upgrade httpie</code>

Red Hat/CentOS:

<code>yum install epel-release
# install
yum install httpie
# upgrade
yum upgrade httpie</code>

Fedora (if preferred):

<code>dnf install httpie</code>

Usage

The basic command format is:

<code>https|http [flags] [METHOD] URL [ITEM [ITEM]]</code>

Run

http --help

for detailed options.

Request Method

The method is optional; httpie infers it automatically. Explicitly specifying a method overrides the inference.

<code>http pie.dev/get</code>
<code>http POST pie.dev/get</code>

Query String Parameters

Use

==

for query parameters and

=

for request‑body fields, eliminating the need for URL‑encoding.

<code>http https://api.github.com/search/repositories q==httpie per_page==1</code>

File‑Based Parameters

Reference external files with

@

to supply headers, query values, or JSON bodies.

<code>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 file</code>

JSON Support

Use

--json

or

-j

to set

Accept: application/json

automatically; key‑value pairs become JSON fields.

<code>http -j PUT pie.dev/put name=felord age=18</code>

Without

-j

, raw JSON values are expressed with

:=

and files with

@

:

<code>http PUT pie.dev/put \
    name=John \
    age:=29 \
    married:=false \
    hobbies:=['"http"','"pies"'] \
    favorite:={"tool":"HTTPie"} \
    bookmarks:=@files/data.json \
    description=@files/text.txt</code>

The resulting request body is:

<code>{
  "name": "John",
  "age": 29,
  "married": false,
  "hobbies": ["http", "pies"],
  "favorite": {"tool": "HTTPie"},
  "bookmarks": {"httpie": {"says": "Hello, World!"}},
  "description": "Hello, World!\n"
}</code>

Nested Structures

Nested JSON can be expressed directly using the same syntax.

Tips and Shortcuts

Quick request syntax:

<code># https://baidu.com
https ://baidu.com</code>

For localhost, omit the scheme:

<code># https://localhost:8080/yourapi
https :8080/yourapi</code>

File upload/download examples:

<code>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.pdf</code>

Additional Note

httpie also offers a UI client currently in beta testing, not yet publicly available.

jsoncommand-lineinstallationAPI testingusagehttpiecurl alternative
macrozheng
Written by

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.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.