{"id":14067383,"url":"https://github.com/r-lib/httr2","last_synced_at":"2025-05-14T08:09:34.497Z","repository":{"id":37609042,"uuid":"158719104","full_name":"r-lib/httr2","owner":"r-lib","description":"Make HTTP requests and process their responses. A modern reimagining of httr.","archived":false,"fork":false,"pushed_at":"2025-05-05T19:52:36.000Z","size":19614,"stargazers_count":248,"open_issues_count":28,"forks_count":67,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-05-14T02:24:15.250Z","etag":null,"topics":["http","r"],"latest_commit_sha":null,"homepage":"https://httr2.r-lib.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-lib.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-11-22T15:32:29.000Z","updated_at":"2025-05-05T19:47:56.000Z","dependencies_parsed_at":"2023-11-22T14:27:22.293Z","dependency_job_id":"de83fd4e-7a45-4331-907e-855187cfa55d","html_url":"https://github.com/r-lib/httr2","commit_stats":{"total_commits":584,"total_committers":45,"mean_commits":"12.977777777777778","dds":0.1986301369863014,"last_synced_commit":"e6f425ee480b9b464a6ab552b6bf7360a1c2181c"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fhttr2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fhttr2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fhttr2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fhttr2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/httr2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101558,"owners_count":22014908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","r"],"created_at":"2024-08-13T07:05:34.047Z","updated_at":"2025-05-14T08:09:29.488Z","avatar_url":"https://github.com/r-lib.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# httr2 \u003ca href=\"https://httr2.r-lib.org\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" alt=\"httr2 website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![R-CMD-check](https://github.com/r-lib/httr2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/httr2/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/r-lib/httr2/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/httr2?branch=main)\n\u003c!-- badges: end --\u003e\n\nhttr2 (pronounced \"hitter2\") is a comprehensive HTTP client that provides a modern, pipeable API for working with web APIs. It builds on top of [{curl}](https://jeroen.r-universe.dev/curl) to provide features like explicit request objects, built-in rate limiting \u0026 retry tooling, comprehensive OAuth support, and secure handling of secrets and credentials.\n\n## Installation\n\nYou can install httr2 from CRAN with:\n\n``` r\ninstall.packages(\"httr2\")\n```\n\n## Usage\n\nTo use httr2, start by creating a **request**:\n\n```{r}\nlibrary(httr2)\n\nreq \u003c- request(\"https://r-project.org\")\nreq\n```\n\nYou can tailor this request with the `req_` family of functions:\n\n```{r}\n# Add custom headers\nreq |\u003e req_headers(\"Accept\" = \"application/json\")\n\n# Add a body, turning it into a POST\nreq |\u003e req_body_json(list(x = 1, y = 2))\n\n# Modify the path in the url\nreq |\u003e req_url_path(path = \"path/to/my/file\")\n\n# Automatically retry if the request fails\nreq |\u003e req_retry(max_tries = 5)\n\n# Change the HTTP method\nreq |\u003e req_method(\"PATCH\")\n```\n\nAnd see exactly what httr2 will send to the server with `req_dry_run()`:\n\n```{r}\nreq |\u003e req_dry_run()\n```\n\nUse `req_perform()` to perform the request, retrieving a **response**:\n\n```{r}\nresp \u003c- req_perform(req)\nresp\n```\n\nThe `resp_` functions help you extract various useful components of the response:\n\n```{r}\nresp |\u003e resp_content_type()\nresp |\u003e resp_status_desc()\nresp |\u003e resp_body_html()\n```\n\n## Major differences to httr\n\n-   You can now create and modify a request without performing it.\n    This means that there's now a single function to perform the request and fetch the result: `req_perform()`.\n    `req_perform()` replaces `httr::GET()`, `httr::POST()`, `httr::DELETE()`, and more.\n\n-   HTTP errors are automatically converted into R errors.\n    Use `req_error()` to override the defaults (which turn all 4xx and 5xx responses into errors) or to add additional details to the error message.\n\n-   You can automatically retry if the request fails or encounters a transient HTTP error (e.g. a 429 rate limit request).\n    `req_retry()` defines the maximum number of retries, which errors are transient, and how long to wait between tries.\n\n-   OAuth support has been totally overhauled to directly support many more flows and to make it much easier to both customise the built-in flows and to create your own.\n\n-   You can manage secrets (often needed for testing) with `secret_encrypt()` and friends.\n    You can obfuscate mildly confidential data with `obfuscate()`, preventing it from being scraped from published code.\n\n-   You can automatically cache all cacheable results with `req_cache()`.\n    Relatively few API responses are cacheable, but when they are it typically makes a big difference.\n\n## Acknowledgements\n\nhttr2 wouldn't be possible without [curl](https://cran.dev/curl/), [openssl](https://cran.dev/openssl/), [jsonlite](https://cran.dev/jsonlite/), and [jose](https://github.com/r-lib/jose/), which are all maintained by [Jeroen Ooms](https://github.com/jeroen).\nA big thanks also go to [Jenny Bryan](https://jennybryan.org) and [Craig Citro](https://www.craigcitro.org) who have given me much useful feedback on both the design of the internals and the user facing API.\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fhttr2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Fhttr2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fhttr2/lists"}