Mastodon hachyterm.io

If you want to interact with an API via the command line, curl is the obvious choice on a Linux machine. Most of the time, curl comes pre-installed on your system.
The command utility is very fast, but not very user-friendly.

curl

Here’s an example for a POST request with json:

curl -d '{"username":"jane","email":"jane@test.cc"}' -H "Content-Type: application/json" -X POST https://desolate-cliffs-02122.herokuapp.com/users

PUT:

curl -d '{"username":"jane","email":"jane@test.cc"}' -H "Content-Type: application/json" -X PUT https://desolate-cliffs-02122.herokuapp.com/users/1

You can find a detailed explanation on GitHub Gists.

httpie

httpie is probably the most well-known alternative to curl. httpie is not as powerful, but easier to use. httpie is written in Python. It feels slower than curl or curlie (below).

Find installation instructions for your OS here.

POST request with json:

http --json POST https://desolate-cliffs-02122.herokuapp.com/users username='jane' email='jane@test.cc'

PUT:

http --json PUT https://desolate-cliffs-02122.herokuapp.com/users/1 username='jane' email='jane@test.cc'

curlie

curlie offers the features of curl, with the interface of httpie. The tool is written in Golang.

You can install it with homebrew, pkg, as a binary.

Example Usage: curlie [CURL_OPTIONS...] [METHOD] URL [ITEM [ITEM]]

POST:

curlie POST https://desolate-cliffs-02123.herokuapp.com/users username='jane' email='jane@test.cc'

PUT:

curlie PUT https://desolate-cliffs-02122.herokuapp.com/users/1 username='jane' email='jane@test.cc'