Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

crul-package

crul


Description

HTTP R client

Package API

HTTP verbs (or HTTP request methods)

  • HttpClient is the main interface for making HTTP requests, and includes methods for each HTTP verb

  • HttpRequest allows you to prepare a HTTP payload for use with AsyncVaried, which provides asynchronous requests for varied HTTP methods

  • Async provides asynchronous requests for a single HTTP method at a time

  • the verb() method can be used on all the above to request a specific HTTP verb

Checking HTTP responses

HttpResponse() has helpers for checking and raising warnings/errors.

  • content-types details the various options for checking content types and throwing a warning or error if the response content type doesn't match what you expect. Mis-matched content-types are typically a good sign of a bad response. There's methods built in for json, xml and html, with the ability to set any custom content type

  • raise_for_status() is a method on HttpResponse() that checks the HTTP status code, and errors with the appropriate message for the HTTP status code, optionally using the package fauxpas if it's installed.

HTTP conditions

We use fauxpas if you have it installed for handling HTTP conditions but if it's not installed we use httpcode

Mocking

Mocking HTTP requests is supported via the webmockr package. See mock for guidance, and https://books.ropensci.org/http-testing/

Caching

Caching HTTP requests is supported via the vcr package. See https://books.ropensci.org/http-testing/

Links

Bug reports/feature requests: https://github.com/ropensci/crul/issues

Author(s)

Scott Chamberlain myrmecocystus@gmail.com


crul

HTTP Client

v1.1.0
MIT + file LICENSE
Authors
Scott Chamberlain [aut, cre] (<https://orcid.org/0000-0003-1444-9135>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.