httr v1.4.1


Monthly downloads



Tools for Working with URLs and HTTP

Useful tools for working with HTTP organised by HTTP verbs (GET(), POST(), etc). Configuration functions make it easy to control additional request components (authenticate(), add_headers() and so on).



Travis build status Codecov test coverage CRAN status

The aim of httr is to provide a wrapper for the curl package, customised to the demands of modern web APIs.

Key features:

  • Functions for the most important http verbs: GET(), HEAD(), PATCH(), PUT(), DELETE() and POST().

  • Automatic connection sharing across requests to the same website (by default, curl handles are managed automatically), cookies are maintained across requests, and a up-to-date root-level SSL certificate store is used.

  • Requests return a standard reponse object that captures the http status line, headers and body, along with other useful information.

    • Response content is available with content() as a raw vector (as = "raw"), a character vector (as = "text"), or parsed into an R object (as = "parsed"), currently for html, xml, json, png and jpeg.

    • You can convert http errors into R errors with stop_for_status().

  • Config functions make it easier to modify the request in common ways: set_cookies(), add_headers(), authenticate(), use_proxy(), verbose(), timeout(), content_type(), accept(), progress().

  • Support for OAuth 1.0 and 2.0 with oauth1.0_token() and oauth2.0_token(). The demo directory has eight OAuth demos: four for 1.0 (twitter, vimeo, withings and yahoo) and four for 2.0 (facebook, github, google, linkedin). OAuth credentials are automatically cached within a project.

httr wouldn't be possible without the hard work of the authors of curl and libcurl. Thanks! httr is inspired by http libraries in other languages, such as Resty, Requests and httparty.


To get the current released version from CRAN:


To get the current development version from github:

# install.packages("devtools")

Functions in httr

Name Description
HEAD Get url HEADers.
PUT Send PUT request to server.
DELETE Send a DELETE request.
Token-class OAuth token objects.
BROWSE Open specified url in browser.
RETRY Retry a request until it succeeds.
GET GET a url.
PATCH Send PATCH request to a server.
VERB VERB a url.
POST POST file to a server.
add_headers Add additional headers to a request.
http_status Give information on the status of a request.
oauth_endpoint Describe an OAuth endpoint.
jwt_signature Generate a JWT signature given credentials.
authenticate Use http authentication.
http_type Extract the content type of a response
modify_url Modify a url.
oauth_endpoints Popular oauth endpoints.
config Set curl options.
cache_info Compute caching information for a response.
parse_http_date Parse and print http dates.
http_condition Generate a classed http condition.
response The response object.
sha1_hash SHA1 hash
sign_oauth Sign an OAuth request
write_disk Control where the response body is written.
write_function S3 object to define response writer.
parse_media Parse a media type.
cookies Access cookies in a response.
content Extract content from a request.
httr_options List available options.
handle_pool Maintain a pool of handles.
has_content Does the request have content associated with it?
content_type Set content-type and accept headers.
init_oauth1.0 Retrieve OAuth 1.0 access token.
oauth_exchanger Walk the user through the OAuth2 dance without a local webserver.
oauth_app Create an OAuth application.
http_error Check for an http error.
guess_media Guess the media type of a path from its extension.
oauth_callback The oauth callback url.
oauth_listener Create a webserver to listen for OAuth callback.
handle Create a handle tied to a particular host.
oauth1.0_token Generate an oauth1.0 token.
httr-package httr makes http easy.
httr_dr Diagnose common configuration problems
get_callback Install or uninstall a callback function
oauth2.0_token Generate an oauth2.0 token.
with_config Execute code with configuration set.
set_cookies Set cookies.
progress Add a progress bar.
parse_url Parse and build urls according to RFC1808.
set_config Set (and reset) global httr configuration.
verbose Give verbose output.
headers Extract the headers from a response
timeout Set maximum request time.
upload_file Upload a file with POST() or PUT().
revoke_all Revoke all OAuth tokens in the cache.
hmac_sha1 HMAC SHA1
use_proxy Use a proxy to connect to the internet.
init_oauth2.0 Retrieve OAuth 2.0 access token.
user_agent Set user agent.
oauth_service_token Generate OAuth token for service accounts.
insensitive Create a vector with case insensitive name matching.
oauth_signature Generate oauth signature.
status_code Extract status code from response.
stop_for_status Take action on http error.
write_stream Process output in a streaming manner.
No Results!

Vignettes of httr

No Results!

Last month downloads


License MIT + file LICENSE
VignetteBuilder knitr
Encoding UTF-8
RoxygenNote 6.1.1
NeedsCompilation no
Packaged 2019-07-30 13:44:18 UTC; hadley
Repository CRAN
Date/Publication 2019-08-05 14:30:02 UTC

Include our badge in your README