CLI Tools2026年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.

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 17/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
CLI Tool
安装
Stage only
信任
信任等级:Established
入口
step-1.md
安全暂存命令
npx -y tokrepo@latest install 224cd323-35d4-11f1-9bc6-00163e2b0d79 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

TL;DR
HTTPie replaces curl with intuitive syntax, colorized output, built-in JSON support, and session management for API work.
§01

What it is

HTTPie is a command-line HTTP client designed for API exploration and testing. It provides an intuitive syntax where headers, query parameters, and JSON data are expressed naturally. Output is automatically formatted and colorized, making API responses readable without piping through jq.

HTTPie targets developers, QA engineers, and anyone who works with HTTP APIs from the terminal. If you find curl's flag syntax hard to remember, HTTPie offers a more ergonomic alternative with sensible defaults.

§02

How it saves time or tokens

This workflow provides installation commands and common usage patterns. Instead of looking up curl flags for POST requests with JSON bodies, you get a natural syntax where http POST url key=value does the right thing. Sessions persist cookies and headers across requests, eliminating repetitive authentication headers.

§03

How to use

  1. Install HTTPie:
# macOS
brew install httpie

# Debian/Ubuntu
sudo apt install httpie

# Python
pip install httpie
  1. Make requests with intuitive syntax:
# GET request
http httpbin.org/get

# POST JSON data
http POST httpbin.org/post name=John age:=30 admin:=true

# Custom headers
http httpbin.org/headers Authorization:'Bearer token123'

# Download a file
http --download https://example.com/file.zip
  1. Use sessions for persistent state:
# Create a named session
http --session=myapi POST api.example.com/login username=admin password=secret

# Subsequent requests reuse cookies and headers
http --session=myapi api.example.com/dashboard
§04

Example

# API testing workflow
# 1. Authenticate and save session
http --session=dev POST https://api.example.com/auth/login \
  email=dev@example.com password=secret

# 2. Create a resource (session carries auth cookie)
http --session=dev POST https://api.example.com/items \
  name='New Item' category='tools' price:=29.99

# 3. List resources with query params
http --session=dev https://api.example.com/items \
  page==1 per_page==20 sort==created_at

# 4. Upload a file
http --session=dev POST https://api.example.com/upload \
  file@./document.pdf
§05

Related on TokRepo

§06

Common pitfalls

  • HTTPie uses = for string values and := for raw JSON (numbers, booleans, arrays). Using = for a number sends it as a string, which may cause API validation errors.
  • The == operator is for query parameters, not equality. http url page==2 adds ?page=2 to the URL.
  • HTTPie defaults to JSON content type for POST requests. To send form data instead, use the --form flag.

常见问题

How does HTTPie compare to curl?+

HTTPie provides a more intuitive syntax, automatic JSON formatting, colorized output, and built-in session management. curl is more versatile for low-level HTTP operations and scripting. HTTPie focuses on developer ergonomics for API testing.

Does HTTPie support authentication?+

Yes. HTTPie supports Basic auth (--auth user:pass), Bearer tokens (Authorization:Bearer token), digest auth, and custom authentication via plugins. Sessions persist auth headers across requests.

Can I use HTTPie in scripts?+

Yes. Use --print=b for body-only output, --check-status to fail on HTTP errors, and --quiet for silent mode. HTTPie returns appropriate exit codes for scripting and can output raw responses without formatting.

Does HTTPie support HTTPS?+

Yes. HTTPie handles HTTPS by default, verifying SSL certificates. Use --verify=no to skip verification for self-signed certificates during development.

Is there a GUI version of HTTPie?+

Yes. HTTPie offers a desktop application and web-based interface at httpie.io. The GUI provides the same intuitive experience with a visual request builder. The CLI and GUI share the same core engine.

引用来源 (3)

讨论

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

相关资产