Learn R Programming

httr

Status

httr is superseded: only changes necessary to keep it on CRAN will be made. We recommend using httr2 instead.


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.

Installation

To get the current released version from CRAN:

install.packages("httr")

To get the current development version from github:

# install.packages("pak")
pak::pak("r-lib/httr")

Code of Conduct

Please note that the httr project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Copy Link

Version

Install

install.packages('httr')

Monthly Downloads

1,003,599

Version

1.4.9

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Hadley Wickham

Last Published

September 1st, 2026

Functions in httr (1.4.9)

httr_dr

Diagnose common configuration problems
http_condition

Generate a classed http condition.
set_cookies

Set cookies.
user_agent

Set user agent.
oauth_endpoint

Describe an OAuth endpoint.
jwt_signature

Generate a JWT signature given credentials.
set_config

Set (and reset) global httr configuration.
use_proxy

Use a proxy to connect to the internet.
modify_url

Modify a url.
oauth_endpoints

Popular oauth endpoints.
verbose

Give verbose output.
timeout

Set maximum request time.
with_config

Execute code with configuration set.
oauth2.0_token

Generate an oauth2.0 token.
oauth1.0_token

Generate an oauth1.0 token.
status_code

Extract status code from response.
oauth_service_token

Generate OAuth token for service accounts.
http_error

Check for an http error.
stop_for_status

Take action on http error.
oauth_signature

Generate oauth signature.
upload_file

Upload a file with POST() or PUT().
http_type

Extract the content type of a response
cache_info

Compute caching information for a response.
handle_pool

Maintain a pool of handles.
write_stream

Process output in a streaming manner.
oauth_app

Create an OAuth application.
oauth_callback

The oauth callback url.
config

Set curl options.
progress

Add a progress bar.
parse_url

Parse and build urls according to RFC3986.
sign_oauth

Sign an OAuth request
has_content

Does the request have content associated with it?
oauth_exchanger

Walk the user through the OAuth2 dance without a local webserver.
httr_options

List available options.
init_oauth1.0

Retrieve OAuth 1.0 access token.
sha1_hash

SHA1 hash
oauth_listener

Create a webserver to listen for OAuth callback.
POST

POST file to a server.
get_callback

Install or uninstall a callback function
cookies

Access cookies in a response.
init_oauth2.0

Retrieve OAuth 2.0 access token.
parse_http_date

Parse and print http dates.
insensitive

Create a vector with case insensitive name matching.
parse_media

Parse a media type.
revoke_all

Revoke all OAuth tokens in the cache.
write_disk

Control where the response body is written.
response

The response object.
write_function

S3 object to define response writer.
DELETE

Send a DELETE request.
BROWSE

Open specified url in browser.
PUT

Send PUT request to server.
HEAD

Get url HEADers.
RETRY

Retry a request until it succeeds.
VERB

VERB a url.
GET

GET a url.
Token-class

OAuth token objects.
PATCH

Send PATCH request to a server.
guess_media

Guess the media type of a path from its extension.
content_type

Set content-type and accept headers.
authenticate

Use http authentication.
content

Extract content from a request.
handle

Create a handle tied to a particular host.
add_headers

Add additional headers to a request.
http_status

Give information on the status of a request.
httr-package

httr makes http easy.
hmac_sha1

HMAC SHA1
headers

Extract the headers from a response