Skip to content

nestfulvshttpclient

NA 11 3 505
55.0 thousand (month) Apr 20 2010 1.1.4(2020-02-07 22:04:51 ago)
707 5 96 ruby
Jul 25 2009 2.6 million (month) 2.9.0(2025-02-22 01:13:49 ago)

Nestful is a Ruby library for making HTTP requests. It is designed to provide a simple, easy-to-use interface for making requests and handling responses. Nestful is often used for making requests to RESTful APIs.

One of the main features of Nestful is its ability to automatically parse JSON and XML responses and return them as Ruby objects. This allows developers to easily access the data returned by an API without having to manually parse the response.

Netful is aimed at interacting with rest APIs and provides a convenient interface (see example below)

HTTPClient is a Ruby gem that provides a simple and flexible interface for making HTTP requests. It's a full-featured HTTP client library with support for cookies, redirects, proxy, and more. It's built on top of the libwww-perl library, which is a widely-used, robust and well-documented library.

Features:

  • methods like GET/HEAD/POST/* via HTTP/1.1.
  • HTTPS(SSL), Cookies, proxy, authentication(Digest, NTLM, Basic), etc.
  • asynchronous HTTP request, streaming HTTP request.
  • debug mode CLI.
  • by contrast with net/http in standard distribution;
  • Cookies support
  • MT-safe
  • streaming POST (POST with File/IO)
  • Digest auth
  • Negotiate/NTLM auth for WWW-Authenticate (requires net/ntlm module; rubyntlm gem)
  • NTLM auth for Proxy-Authenticate (requires 'win32/sspi' module; rubysspi gem)
  • extensible with filter interface
  • you don't have to care HTTP/1.1 persistent connection (httpclient cares instead of you)

Example Use


```ruby require 'nestful' # GET request response = Nestful.get('http://httpbin.org/get') puts response.body puts response.code puts response.headers # POST request response = Nestful.post( 'http://httpbin.org/post', :format => :json, :payload => { :title => 'foo', :body => 'bar', :userId => 1 } ) puts response.body # establish interface to a specific API class Charge < Nestful::Resource endpoint 'https://api.stripe.com/v1/charges' options :auth_type => :bearer, :password => 'sk_bar' def self.all self.new(get) end def self.find(id) self.new(get(id)) end def refund post(:refund) end end Charge.all #=> [] Charge.find('ch_bar').amount ```
```ruby require 'httpclient' client = HTTPClient.new # GET requests response = client.get("http://httpbin.org/get") puts response.content # POST requests data = { name: "value" } response = client.post("http://httpbin.org/post", data) puts response.content ```

Alternatives / Similar


Was this page helpful?