Scripts2026年4月11日·1 分钟阅读

HTTPie CLI — Modern User-Friendly Command-Line HTTP Client

HTTPie is a modern, user-friendly command-line HTTP client for the API era. Intuitive syntax, formatted and colorized output, JSON support, sessions, authentication, file uploads, and plugins. The friendly alternative to curl for API exploration.

SC
Script Depot · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

# Install
brew install httpie                        # macOS
sudo apt install httpie                    # Debian/Ubuntu
pip install httpie                         # Python

Basic usage:

http GET https://api.github.com/users/williamwangai
http POST https://api.example.com/users name=William email=w@example.com
http PUT https://api.example.com/users/1 name=Alice
http DELETE https://api.example.com/users/1

# Headers
http GET https://api.example.com Authorization:"Bearer token" X-Custom:value

# JSON body
http POST api.example.com/users <<<"{\"name\":\"William\"}"

# File upload
http --form POST api.example.com/upload file@./photo.jpg

# Download
http --download https://example.com/file.zip

# Sessions (persist cookies/auth)
http --session=work api.example.com/login name=william password=secret
http --session=work api.example.com/me
介绍

HTTPie is a modern command-line HTTP client designed for humans. Its goal is to make CLI interaction with web services as human-friendly as possible. Provides a simple http command that allows for sending arbitrary HTTP requests using a simple and natural syntax, and displays colorized output.

What HTTPie Does

  • Simple syntaxhttp GET url instead of curl -X GET url
  • JSON by defaultkey=value builds JSON request body
  • Colorized output — syntax-highlighted response
  • Sessions — persist cookies and auth across requests
  • File uploadsfile@path syntax
  • Downloads--download flag
  • Auth — Basic, Bearer, Digest, HAWK
  • Plugins — auth, transport, formatter plugins
  • Offline mode — preview what would be sent
  • HTTPS — verify certs, client certs

Architecture

Python-based CLI wrapping the Requests library (and newer python-httpx under the hood). Custom parser for the intuitive request syntax. Pygments for output highlighting.

Self-Hosting

CLI tool, Python package.

Key Features

  • Human-friendly syntax
  • JSON-first
  • Colorized and formatted output
  • Sessions
  • Plugin architecture
  • File uploads
  • Downloads with progress bar
  • Local and remote HTTPS
  • Offline request preview

Comparison

Tool Syntax JSON Colors
HTTPie Intuitive Native Yes
curl POSIX Manual No
wget POSIX Manual No
xh Intuitive (fork) Native Yes (Rust)
Hurl Own DSL Native Yes

常见问题 FAQ

Q: 和 curl 对比? A: curl 是万能的(上传、socks、HTTP2/3、各种低层选项),HTTPie 是人性化的(REST/JSON 交互友好)。日常 API 调试用 HTTPie,底层细节用 curl。

Q: 有没有更快的? A: 有 xh(Rust 重写,启动更快,兼容 HTTPie 语法),但 HTTPie 插件生态更大。

Q: 支持 GraphQL 吗? A: 支持。有 httpie-plugin-graphql 或直接发 POST JSON body。

来源与致谢 Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产