← 返回命令列表

Linux command

httpie 命令

网络

复制后可按需替换文件名、目录或参数。

常用示例

Simple GET request

http [https://api.example.com/users]

POST with JSON

http POST [https://api.example.com/users] name=John age:=30

POST form data

http -f POST [url] name=John email=john@example.com

Add custom header

http [url] Authorization:"Bearer [token]"

Download file

http --download [https://example.com/file.zip]

Authenticated request

http -a [user:password] [url]

Follow redirects

http --follow [url]

Show verbose request and response

http --verbose [url]

Show only response headers

http --headers [url]

说明

HTTPie is a user-friendly HTTP client for the command line. It provides intuitive syntax, colored output, and sensible defaults for API testing and debugging.

参数

--json, -j
JSON data (default).
--form, -f
Form data.
--headers, -h
Print only headers.
--body, -b
Print only body.
--download, -d
Download file.
--follow, -F
Follow redirects.
--auth, -a _user:pass_
Basic authentication.
--auth-type, -A _type_
Auth type: basic, digest, bearer.
--verbose, -v
Print entire HTTP exchange (request and response).
--print, -p _what_
Selectively print: H (request headers), B (request body), h (response headers), b (response body), m (metadata).
--verify _verify_
SSL certificate verification. Set to "no" to skip.
--timeout _seconds_
Connection timeout in seconds (default: 30).
--proxy _protocol:url_
Set proxy (e.g., http:http://proxy:8080).
--check-status
Exit with error on HTTP 3xx/4xx/5xx status codes.
--output, -o _file_
Save response body to file.
--session _name_
Named session for persisting cookies/auth/headers.
--pretty _mode_
Output formatting: all, colors, format, none.
--offline
Build request offline without sending.

FAQ

What is the httpie command used for?

HTTPie is a user-friendly HTTP client for the command line. It provides intuitive syntax, colored output, and sensible defaults for API testing and debugging.

How do I run a basic httpie example?

Run `http [https://api.example.com/users]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --json, -j do in httpie?

JSON data (default).