vcr

Record and replay HTTP requests

https://github.com/ropensci/vcr

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.6%) to scientific vocabulary

Keywords

mocking r r-package rstats testing unit-testing vcr

Keywords from Contributors

http-mock genome taxonomy geocoding ropensci testing-tools taxize nomenclature darwincore biology
Last synced: 4 months ago · JSON representation

Repository

Record and replay HTTP requests

Basic Info
Statistics
  • Stars: 93
  • Watchers: 4
  • Forks: 14
  • Open Issues: 44
  • Releases: 16
Topics
mocking r r-package rstats testing unit-testing vcr
Created about 11 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Codemeta

README.Rmd

---
output: github_document
---



```{r echo=FALSE}
knitr::opts_chunk$set(
  comment = "#>",
  collapse = TRUE,
  warning = FALSE,
  message = FALSE
)
```

# vcr 

[![cran checks](https://badges.cranchecks.info/worst/vcr.svg)](https://CRAN.R-project.org/package=vcr)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![R-check](https://github.com/ropensci/vcr/workflows/R-check/badge.svg)](https://github.com/ropensci/vcr/actions/)
[![codecov](https://codecov.io/gh/ropensci/vcr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ropensci/vcr)
[![rstudio mirror downloads](https://cranlogs.r-pkg.org/badges/vcr)](https://github.com/r-hub/cranlogs.app)
[![cran version](https://www.r-pkg.org/badges/version/vcr)](https://cran.r-project.org/package=vcr)


{vcr} records and replays HTTP requests so you can test your API package with speed and confidence. It makes your tests independent of your internet connection (so they work on CRAN!) and because your tests get much much faster, you can write even more, increasing the coverage of your package. {vcr} works with {crul}, {httr} and {httr2}.

{vcr} draws inspiration from Ruby's [vcr](https://github.com/vcr/vcr).

## Installation

```{r}
#| eval: false
# Install the latest released version from CRAN
install.packages("vcr")

# Or install the development version
# from R-universe
install.packages(
  "vcr",
  repos = c("https://ropensci.r-universe.dev", "https://cloud.r-project.org")
)

# Or from GitHub:
# install.packages("pak")
pak::pak("ropensci/vcr")
```

## Usage

Using vcr in a test is straightforward: just call `vcr::local_cassette()`. The first time your test is run, vcr will automatically record every HTTP request, saving the request and reponse in `tests/testthat/_vcr`. After that, it will replay those recorded requests, meaning that your test no longer needs an active connection.

```{r}
#| eval: false
test_that("can retrieve current version", {
  vcr::local_cassette("rl_version")
  expect_equal(rredlist::rl_version(), "2025-1")
})
```

The first argument to `local_cassette()` is the cassette name: it's used to name the cassette file so needs to be unique across tests. In this case, running the above test will generate `tests/testthat/_vcr/rl_version.yaml` which looks something like this:

```yaml
http_interactions:
- request:
    method: GET
    uri: https://api.iucnredlist.org/api/v4/information/red_list_version
  response:
    status: 200
    headers:
      status: 'HTTP/2 200 '
      cache-control: max-age=0, private, must-revalidate
      content-type: application/json
      etag: W/"1694e95e54c5590a355e5922b47c7cd9"
      date: Tue, 06 May 2025 20:52:22 GMT
    body:
      string: '{"red_list_version":"2025-1"}'
  recorded_at: 2025-05-06 20:52:21
recorded_with: VCR-vcr/2.0.0
```

If you look carefully at this file, you'll notice an `Authorization` header is not recorded in the request headers despite it being used in the actual HTTP request. Read more about protecting secrets in the vignette `vignette("secrets")`.

## Learn more

Start with `vignette("vcr")` to learn more about how {vcr} works, especially how requests are matched to the recordeded cassette. You might also enjoy the [HTTP testing](https://books.ropensci.org/http-testing/) book for a lot more details about {vcr}, {webmockr}, {curl} and more.

## Meta

* Please [report any issues or bugs](https://github.com/ropensci/vcr/issues)
* License: MIT
* Get citation information for `vcr` in R doing `citation(package = 'vcr')`
* Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.

Owner

  • Name: rOpenSci
  • Login: ropensci
  • Kind: organization
  • Email: info@ropensci.org
  • Location: Berkeley, CA

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "identifier": "vcr",
  "description": "Record test suite 'HTTP' requests and replays them during future runs. A port of the Ruby gem of the same name (<https://github.com/vcr/vcr/>). Works by recording real 'HTTP' requests/responses on disk in 'cassettes', and then replaying matching responses on subsequent requests.",
  "name": "vcr: Record 'HTTP' Calls to Disk",
  "relatedLink": [
    "https://books.ropensci.org/http-testing/",
    "https://docs.ropensci.org/vcr/"
  ],
  "codeRepository": "https://github.com/ropensci/vcr/",
  "issueTracker": "https://github.com/ropensci/vcr/issues",
  "license": "https://spdx.org/licenses/MIT",
  "version": "2.0.0",
  "programmingLanguage": {
    "@type": "ComputerLanguage",
    "name": "R",
    "url": "https://r-project.org"
  },
  "runtimePlatform": "R version 4.5.1 (2025-06-13)",
  "provider": {
    "@id": "https://cran.r-project.org",
    "@type": "Organization",
    "name": "Comprehensive R Archive Network (CRAN)",
    "url": "https://cran.r-project.org"
  },
  "author": [
    {
      "@type": "Person",
      "givenName": "Scott",
      "familyName": "Chamberlain",
      "email": "myrmecocystus@gmail.com",
      "@id": "https://orcid.org/0000-0003-1444-9135"
    },
    {
      "@type": "Person",
      "givenName": "Aaron",
      "familyName": "Wolen",
      "@id": "https://orcid.org/0000-0003-2542-2202"
    },
    {
      "@type": "Person",
      "givenName": "Malle",
      "familyName": "Salmon",
      "@id": "https://orcid.org/0000-0002-2815-0399"
    },
    {
      "@type": "Person",
      "givenName": "Daniel",
      "familyName": "Possenriede",
      "@id": "https://orcid.org/0000-0002-6738-9845"
    },
    {
      "@type": "Person",
      "givenName": "Hadley",
      "familyName": "Wickham",
      "email": "hadley@posit.co"
    }
  ],
  "funder": [
    {
      "@type": "Organization",
      "name": "rOpenSci"
    }
  ],
  "maintainer": [
    {
      "@type": "Person",
      "givenName": "Scott",
      "familyName": "Chamberlain",
      "email": "myrmecocystus@gmail.com",
      "@id": "https://orcid.org/0000-0003-1444-9135"
    }
  ],
  "softwareSuggestions": [
    {
      "@type": "SoftwareApplication",
      "identifier": "crul",
      "name": "crul",
      "version": ">= 1.6.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=crul"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "desc",
      "name": "desc",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=desc"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "httr",
      "name": "httr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=httr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "httr2",
      "name": "httr2",
      "version": ">= 1.1.2",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=httr2"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "knitr",
      "name": "knitr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=knitr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "qs2",
      "name": "qs2",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=qs2"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "rmarkdown",
      "name": "rmarkdown",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rmarkdown"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "roxygen2",
      "name": "roxygen2",
      "version": ">= 7.2.1",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=roxygen2"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "testthat",
      "name": "testthat",
      "version": ">= 3.0.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=testthat"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "webfakes",
      "name": "webfakes",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=webfakes"
    }
  ],
  "softwareRequirements": {
    "1": {
      "@type": "SoftwareApplication",
      "identifier": "R",
      "name": "R",
      "version": ">= 4.1"
    },
    "2": {
      "@type": "SoftwareApplication",
      "identifier": "cli",
      "name": "cli",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=cli"
    },
    "3": {
      "@type": "SoftwareApplication",
      "identifier": "curl",
      "name": "curl",
      "version": ">= 6.3.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=curl"
    },
    "4": {
      "@type": "SoftwareApplication",
      "identifier": "jsonlite",
      "name": "jsonlite",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=jsonlite"
    },
    "5": {
      "@type": "SoftwareApplication",
      "identifier": "lifecycle",
      "name": "lifecycle",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=lifecycle"
    },
    "6": {
      "@type": "SoftwareApplication",
      "identifier": "R6",
      "name": "R6",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=R6"
    },
    "7": {
      "@type": "SoftwareApplication",
      "identifier": "rlang",
      "name": "rlang",
      "version": ">= 1.1.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rlang"
    },
    "8": {
      "@type": "SoftwareApplication",
      "identifier": "rprojroot",
      "name": "rprojroot",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rprojroot"
    },
    "9": {
      "@type": "SoftwareApplication",
      "identifier": "waldo",
      "name": "waldo",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=waldo"
    },
    "10": {
      "@type": "SoftwareApplication",
      "identifier": "withr",
      "name": "withr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=withr"
    },
    "11": {
      "@type": "SoftwareApplication",
      "identifier": "yaml",
      "name": "yaml",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=yaml"
    },
    "SystemRequirements": null
  },
  "applicationCategory": "Web",
  "isPartOf": "https://ropensci.org",
  "keywords": [
    "http",
    "https",
    "API",
    "web-services",
    "curl",
    "mock",
    "mocking",
    "http-mocking",
    "testing",
    "testing-tools",
    "tdd"
  ],
  "fileSize": "673.073KB"
}

GitHub Events

Total
  • Create event: 106
  • Release event: 2
  • Issues event: 77
  • Watch event: 10
  • Delete event: 92
  • Member event: 1
  • Issue comment event: 354
  • Push event: 366
  • Pull request review event: 151
  • Pull request review comment event: 141
  • Pull request event: 370
  • Fork event: 3
Last Year
  • Create event: 106
  • Release event: 2
  • Issues event: 77
  • Watch event: 10
  • Delete event: 92
  • Member event: 1
  • Issue comment event: 354
  • Push event: 366
  • Pull request review event: 151
  • Pull request review comment event: 141
  • Pull request event: 370
  • Fork event: 3

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 685
  • Total Committers: 16
  • Avg Commits per committer: 42.813
  • Development Distribution Score (DDS): 0.206
Past Year
  • Commits: 7
  • Committers: 3
  • Avg Commits per committer: 2.333
  • Development Distribution Score (DDS): 0.286
Top Committers
Name Email Commits
Scott Chamberlain m****s@g****m 544
Maëlle Salmon m****n@y****e 62
Aaron Wolen a****n@w****m 45
Daniel Possenriede p****e@g****m 13
David Parr d****r@g****m 5
alex gable a****e@g****m 3
Lluís l****a@g****m 2
Kevin Cazelles k****e@u****a 2
Jeroen Ooms j****s@g****m 2
Patrick Schratz p****z@g****m 1
Kevin Cazelles k****s@g****m 1
zachary-foster z****9@g****m 1
olivroy 5****y 1
Rekyt m****e@e****r 1
Bryce Mecum p****h@g****m 1
Adam H. Sparks a****s@i****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 132
  • Total pull requests: 452
  • Average time to close issues: about 1 year
  • Average time to close pull requests: 1 day
  • Total issue authors: 22
  • Total pull request authors: 11
  • Average comments per issue: 4.16
  • Average comments per pull request: 1.08
  • Merged pull requests: 394
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 48
  • Pull requests: 422
  • Average time to close issues: 11 days
  • Average time to close pull requests: 1 day
  • Issue authors: 9
  • Pull request authors: 4
  • Average comments per issue: 1.4
  • Average comments per pull request: 1.0
  • Merged pull requests: 366
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sckott (62)
  • maelle (27)
  • hadley (16)
  • llrs (4)
  • dpprdan (2)
  • christopherkenny (2)
  • drmowinckels (2)
  • KevCaz (2)
  • RichardLitt (1)
  • alex-gable (1)
  • zachary-foster (1)
  • bretsw (1)
  • juliasilge (1)
  • amoeba (1)
  • steffilazerte (1)
Pull Request Authors
  • hadley (392)
  • maelle (23)
  • sckott (19)
  • dpprdan (5)
  • DaveParr (2)
  • RichardLitt (2)
  • jimrothstein (2)
  • olivroy (2)
  • adamhsparks (1)
  • llrs (1)
  • KevCaz (1)
Top Labels
Issue Labels
bug (10) docs (7) security (7) filters (4) informing-the-user (4) logging (3) httr2 (3) hooks (3) usecase (2) os-windows (2) redirects (2) later (2) httr (1) before-record (1) question (1) persisters (1) serializers (1)
Pull Request Labels
docs (28) httr2 (2) logging (2) serializers (1) tooling (1)

Packages

  • Total packages: 2
  • Total downloads:
    • cran 3,706 last-month
  • Total docker downloads: 42,875
  • Total dependent packages: 69
    (may contain duplicates)
  • Total dependent repositories: 129
    (may contain duplicates)
  • Total versions: 34
  • Total maintainers: 1
cran.r-project.org: vcr

Record 'HTTP' Calls to Disk

  • Versions: 17
  • Dependent Packages: 69
  • Dependent Repositories: 129
  • Downloads: 3,706 Last month
  • Docker Downloads: 42,875
Rankings
Docker downloads count: 0.6%
Dependent packages count: 1.3%
Dependent repos count: 1.8%
Average: 3.6%
Stargazers count: 4.7%
Forks count: 5.8%
Downloads: 7.5%
Maintainers (1)
Last synced: 4 months ago
proxy.golang.org: github.com/ropensci/vcr
  • Versions: 17
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.7%
Dependent repos count: 5.9%
Last synced: 4 months ago

Dependencies

DESCRIPTION cran
  • R6 * imports
  • base64enc * imports
  • crul >= 0.8.4 imports
  • httr * imports
  • rprojroot * imports
  • urltools * imports
  • webmockr >= 0.8.0 imports
  • yaml * imports
  • cli * suggests
  • crayon * suggests
  • curl * suggests
  • desc * suggests
  • jsonlite * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • roxygen2 >= 7.1.1 suggests
  • testthat * suggests
  • withr * suggests
.github/workflows/R-check.yaml actions
  • actions/checkout v2 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/revdep-check.yaml actions
  • actions/checkout v2 composite
  • actions/upload-artifact v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite