Skip to content

superagentvsnestful

MIT 176 16 16,564
38.7 million (month) Aug 22 2011 9.0.2(2 months ago)
507 3 11 NA
Apr 20 2010 41.3 thousand (month) 1.1.4(4 years ago)

superagent is an HTTP client library for Node.js that provides a simple, flexible, and powerful API for making HTTP requests. It supports all major HTTP methods, and has a clean and easy-to-use interface for handling responses and errors.

what differentiates superagent from other http clients is its simple declarative API.

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)

Highlights


declarativeproxypopular

Example Use


const superagent = require('superagent');

// superagent supports both Promises and async/await
superagent.get('https://httpbin.org/get')
    .then(res => console.log(res.text))
    .catch(err => console.error(err));
const response = superagent.get('https://httpbin.org/get')

// post requests:
superagent.post('https://httpbin.org/post').send({ name: 'John Doe' })

// setting proxy
superagent.get('https://httpbin.org/ip').proxy('http://proxy.example.com:8080')

// settings headers and proxies
superagent.get('https://httpbin.org/headers').set('Cookie', 'myCookie=123').set('X-My-Header', 'myValue')
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

Alternatives / Similar


Was this page helpful?