Nestful: A Simple Ruby HTTP/REST Client Library
Nestful is a simple HTTP/REST client library for Ruby, developed by Alex MacCaw (of Juggernaut) fame. Nestful allows you to consume basic Web services easily, usually in a single line of code. It can deal with JSON, buffered downloads, and callbacks out of the box.
HTTParty is the current, de-facto simple HTTP/REST client library used by most Rubyists (when net/http
won't do or when Typhoeus is too overkill) but Nestful differs enough from HTTParty to live alongside it. While HTTParty encourages you to build up some structure and separate the types of resources you're accessing into classes (that HTTParty then extends), Nestful offers a simpler, "just call a method from anywhere" approach.
Some basic Nestful examples:
Nestful.get 'http://example.com' #=> "body" Nestful.post 'http://example.com', :format => :form #=> "body" Nestful.get 'http://example.com', :params => {:nestled => {:params => 1}} Nestful.get 'http://example.com', :format => :json #=> {:json_hash => 1} Nestful::Resource.new('http://example.com')['assets'][1].get(:format => :xml) #=> {:xml_hash => 1}
Nestful's features include:
- Simple API
- File buffering
- Before/Progress/After Callbacks
- JSON & XML requests
- Multipart requests (file uploading)
- Resource API
- Proxy support
- SSL support
April 28, 2010 at 4:28 pm
This is different from REST Client how?
April 28, 2010 at 5:57 pm
Technocrat,
You're right - this is similar to RestClient. However, I guess I made Nestful as an act of stubbornness of my part - I personally didn't like RestClient's code or API - and had a enough issues with it to make my own library.
Alex
April 28, 2010 at 10:56 pm
Your post has been linked at the drink rails blog.
May 18, 2010 at 5:07 am
Hey, are there some examples of how this is used in an application?