Learn R Programming

⚠️There's a newer version (1.4.7) of this package.Take me there.

httr

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("devtools")
devtools::install_github("r-lib/httr")

Copy Link

Version

Install

install.packages('httr')

Monthly Downloads

833,627

Version

1.3.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

August 20th, 2017

Functions in httr (1.3.1)

GET

GET a url.
HEAD

Get url HEADers.
BROWSE

Open specified url in browser.
DELETE

Send a DELETE request.
PUT

Send PUT request to server.
RETRY

Retry a request until it succeeds.
Token-class

OAuth token objects.
VERB

VERB a url.
PATCH

Send PATCH request to a server.
POST

POST file to a server.
add_headers

Add additional headers to a request.
authenticate

Use http authentication.
httr-package

httr makes http easy.
httr_dr

Diagnose common configuration problems
jwt_signature

Generate a JWT signature given credentials.
modify_url

Modify a url.
parse_http_date

Parse and print http dates.
guess_media

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

Create a handle tied to a particular host.
http_status

Give information on the status of a request.
http_type

Extract the content type of a response
cache_info

Compute caching information for a response.
config

Set curl options.
http_condition

Generate a classed http condition.
http_error

Check for an http error.
oauth_app

Create an OAuth application.
oauth_callback

The oauth callback url.
oauth_exchanger

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

Create a webserver to listen for OAuth callback.
status_code

Extract status code from response.
init_oauth2.0

Retrieve OAuth 2.0 access token.
insensitive

Create a vector with case insensitive name matching.
oauth_endpoint

Describe an OAuth endpoint.
oauth_endpoints

Popular oauth endpoints.
sign_oauth

Sign an OAuth request
stop_for_status

Take action on http error.
write_stream

Process output in a streaming manner.
parse_media

Parse a media type.
timeout

Set maximum request time.
upload_file

verbose

Give verbose output.
with_config

Execute code with configuration set.
sha1_hash

SHA1 hash
content

Extract content from a request.
content_type

Set content-type and accept headers.
handle_pool

Maintain a pool of handles.
has_content

Does the request have content associated with it?
oauth1.0_token

Generate an oauth1.0 token.
cookies

Access cookies in a response.
get_callback

Install or uninstall a callback function
headers

Extract the headers from a response
hmac_sha1

HMAC SHA1
httr_options

List available options.
init_oauth1.0

Retrieve OAuth 1.0 access token.
parse_url

Parse and build urls according to RFC1808.
progress

Add a progress bar.
response

The response object.
oauth2.0_token

Generate an oauth2.0 token.
oauth_service_token

Generate OAuth token for service accounts.
oauth_signature

Generate oauth signature.
set_config

Set (and reset) global httr configuration.
revoke_all

Revoke all OAuth tokens in the cache.
use_proxy

Use a proxy to connect to the internet.
user_agent

Set user agent.
set_cookies

Set cookies.
write_disk

Control where the response body is written.
write_function

S3 object to define response writer.