Wynn Netherland changelog.com/posts

resty: Piping hot REST client for bash or zsh

I love REST APIs, so I’m always looking for new tools for the toolbox. Resty from Micha Niskin caught my eye because it can be loaded into your bash or zsh. To install, just download the script and source it.

$ curl http://github.com/micha/resty/raw/master/resty > resty
$ . resty

Now your shell is loaded up with the Resty commands. First, set an API endpoint, like GitHub:

$ resty http://github.com
http://github.com*

Now we can make any normal GET, POST, PUT, or DELETE as you would expect.

GET /pengwynn.json

For formatted output, pipe it to pretty print:

GET /pengwynn.json | pp

… or save to a file

GET /pengwynn.json > me.json

REST on the Couch

Resty is perfect for CouchDB. Just set your endpoint

resty http://127.0.0.1:5984

… and you’re ready to create datbases

PUT /test '{}'

… and stash documents.

PUT /test/me < me.json

cURL-ing

Since Resty sits on top cURL, any additional options after the required path will be passed along to cURL:

resty http://github.com/api/v2/json
GET /repos/show/pengwynn -u pengwynn:0U812

Be sure to check out Jan-Piet Mens’ introductory screencast or the README for advanced usage.

[Source on GitHub] [Screencast]


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00