Skip to content

nestfulvsfaraday

NA 11 3 505
55.0 thousand (month) Apr 20 2010 1.1.4(2020-02-07 22:04:51 ago)
5,927 8 60 MIT
Dec 19 2009 5.9 million (month) 2.14.1(2026-02-07 15:17:15 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)

Faraday is a Ruby gem that provides a simple and flexible interface for making HTTP requests. It allows you to create a Faraday connection object, which you can use to send requests and receive responses.

Faraday abstracts away the details of the underlying HTTP client library, so you can use it with different libraries such as Net::HTTP, HTTPClient, typhoeus and others.

Since Faraday can adapt many other HTTP clients it's very popular choice in web scraping.

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 # GET requests response = Faraday.get('http://httpbingo.org') put response.status put response.headers put response.body # or use a persistent client session: conn = Faraday.new( url: 'http://httpbin.org/get', params: {param: '1'}, headers: {'Content-Type' => 'application/json'} ) # POST requests response = conn.post('/post') do |req| req.params['limit'] = 100 req.body = {query: 'chunky bacon'}.to_json end ```

Alternatives / Similar


Was this page helpful?