cURL vs HTTPie: Interacting with HTTP servers
- 1 min
For testing and debugging while developing RESTful APIs or HTTP servers or even playing around with APIs, cURL used to be my default tool of choice. However, my life literally changed once I found out about HTTPie. HTTPie is a command line HTTP client written in python that allows for sending arbitrary HTTP requests using a simple and natural syntax, and displays colorized output.
Let’s make some GET and POST requests using curl and httpie and see the difference in request syntax as well as responses.
GET Request
-
cURL
curl 'https://postman-echo.com/get?arg1=value1&key2=value2'
Response:
-
HTTPie
https https://postman-echo.com/get arg1==value1 arg2==value2
Response:
POST Request
-
cURL
curl -d '{"key1":"value1", "key2":"value2"}' \ -H "Content-Type: application/json" \ -X POST https://postman-echo.com/post
Response:
-
HTTPie
https POST https://postman-echo.com/post key1=value1 key2=value2
Response:
Installation
Installing HTTPie is pretty simple using pip.
pip install httpie
I really like HTTPie due to its expressive and intuitive syntax, formatted and colorized terminal output and built-in JSON support. I recommend you try it as well.