Compared to curl command, Httpie provide a clearer friendly interface, and supports authorized agents and other operations
Key Features
- Intuitive syntax
- And color format of the output terminal
- Built-in support for JSON
- Support and file upload form
- HTTPS, proxy and authentication
- Any request data
- Custom header
- Persistent sessions
- Class Wget download
- Support Python 2.6, 2.7 and 3.x
- Support for Linux, Mac OS X and Windows
- Plug
- File
- Test coverage
installation method
pip install httpie
Use
Httpie command http
,? All options (request method, request header, request data) are separated by a space
- Request method: the GET / POST / the DELETE / the PUT / ...
(the default is no data GET, POST request data by default) - Request header: in order to
:
separate, asContent-Type: application/json
- Request data: to
=
separate the plurality of parameters separated by spaces, such asname=张三 password=123456
when the parameter value is not a string, in:=
spaced apart, such asa:=1 b:=true
request the default type as JSON, use-f
was form type
Examples
- GET request (parameters can be written in the url)
http 'http://115.28.108.130:5000/add/?a=1&b=2'
- POST request form classes
http -f 'http://115.28.108.130:5000/api/user/login/' name=张三 password=123456
- JSON format request
http 'http://115.28.108.130:5000/api/user/reg/' name=张三 password=123456
- Carry Cookie
(intermediate special characters can be used''
in quotes)
http http://115.28.108.130:5000/api/user/getUserList/ Cookie:'PYSESSID=05eac6ba-2eb6-11e9-a130-00163e06e52c;session=eyIwNWVhYzZiYS0yZWI2LTExZTktYTEzMC0wMDE2M2UwNmU1MmMiOnRydWV9.D0Q51A.u9XjrAZb-plUSl01QnNPkGXJPck'
- Basic Auth interfaces
used-a 用户名:密码
to transmit Basic Auth interfaces, such as:
http -a superhin001:hanzhichao520 https://api.github.com/user
Reference article: Sunshine main island: HTTPIE tool Getting Started