REST Client -- simple DSL for accessing HTTP and REST resources
A simple HTTP and REST client for Ruby, inspired by the Sinatra's microframework style of specifying actions: get, put, post, delete.
- Main page: https://github.com/rest-client/rest-client
- Mailing list: https://groups.io/g/rest-client
New mailing list
We have a new email list for announcements, hosted by Groups.io.
-
Subscribe on the web: https://groups.io/g/rest-client
-
Subscribe by sending an email: mailto:rest-client+subscribe@groups.io
-
Open discussion subgroup: https://groups.io/g/rest-client+discuss
The old Librelist mailing list is defunct, as Librelist appears to be broken and not accepting new mail. The old archives are still up, but have been imported into the new list archives as well. http://librelist.com/browser/rest.client
Requirements
MRI Ruby 2.0 and newer are supported. Alternative interpreters compatible with 2.0+ should work as well.
Earlier Ruby versions such as 1.8.7, 1.9.2, and 1.9.3 are no longer supported. These versions no longer have any official support, and do not receive security updates.
The rest-client gem depends on these other gems for usage at runtime:
There are also several development dependencies. It's recommended to use bundler to manage these dependencies for hacking on rest-client.
Upgrading to rest-client 2.0 from 1.x
Users are encouraged to upgrade to rest-client 2.0, which cleans up a number of API warts and wrinkles, making rest-client generally more useful. Usage is largely compatible, so many applications will be able to upgrade with no changes.
Overview of significant changes:
- requires Ruby >= 2.0
RestClient::Responseobjects are a subclass ofStringrather than a Frankenstein monster. And#bodyor#to_sreturn a trueStringobject.- cleanup of exception classes, including new
RestClient::Exceptions::Timeout - improvements to handling of redirects: responses and history are properly exposed
- major changes to cookie support: cookie jars are used for browser-like behavior throughout
- encoding: Content-Type charset response headers are used to automatically set the encoding of the response string
- HTTP params: handling of GET/POST params is more consistent and sophisticated
for deeply nested hash objects, and
ParamsArraycan be used to pass ordered params - improved proxy support with per-request proxy configuration, plus the ability to disable proxies set by environment variables
- default request headers: rest-client sets
Accept: */*andUser-Agent: rest-client/...
See history.md for a more complete description of changes.
Usage: Raw URL
Basic usage:
require 'rest-client' RestClient.get(url, headers={}) RestClient.post(url, payload, headers={})
In the high level helpers, only POST, PATCH, and PUT take a payload argument.
To pass a payload with other HTTP verbs or to pass more advanced options, use
RestClient::Request.execute instead.
More detailed examples: