Skip to contents

Use beekeeper to create and maintain R packages that wrap APIs. The generated packages follow best practices, including documentation and testing.

This package focuses on APIs that follow the OpenAPI Specification (OAS). Currently versions 3.0 and 3.1 are supported, with support for swagger 2.0 to come. The APIs must have an API document in yaml format. The package skeletons generated by beekeeper implement best practices to streamline package development.

The Plan

This project has been accepted by the R Consortium 2023 ISC Grant Program!

This is a rough outline of the planned development milestones of this package, working toward a stable version 1.0.0. Most of the outline was included in the grant proposal.

    • I split the OpenAPI-parsing functionality into a separate package, {rapid}. That package is being developed parallel to this one, and contains all of the R API Definition-specific functionality.
    • I also realized I need a package for wrapping {httr2} calls. That package is called {nectar}, and is also being developed parallel to this one.
    • Export a function or functions to generate R/*.R files to call an API, given the URL of an OpenAPI spec in YAML format (or a rapid::class_rapid() object). The generated files will follow and encourage best practices, and will serve as the core around which the rest of a package would be built.
    • Also generate a tests/testthat/*.R file for that generated function.
    • Generate R/*.R and tests/testthat/*.R files to authenticate the user (using API keys).
    • Produce a vignette about configuring authentication. Folded into the main vignette since it’s suprisingly straightforward.
    • Add support for APIs using the OAS json format.
    • Streamline discovery of API definitions (with associated error handling).
      • UPDATE: This functionality is in a separate package, {anyapi}.
    • Generate R/.R and tests/testthat/.R files for all endpoints (“paths”) described in the given API specification.
    • The generated functions will work, but error checking, documentation, and tests will be minimal.
    • Potential challenges: I’ll need to strike a balance here between getting a basic working system and producing something that can be easily expanded later.
      • Update: Also, this likely could go unsaid, but, if the API description is incorrect, the functions will not work as expected. Hopefully their error messages will be helpful for debugging, though!
    • Add documentation for implementing batching and rate-limiting.
    • If possible, export functionality to help implement these processes, but standards seem to vary widely.
    • Potential challenges: This step will involve more reading and documenting than code, to gather examples of how different APIs implement limits and batching. It’s possible systems will be so different that it will be difficult to summarize them. For example, Slack has two separate batching systems in its API, with some functions moved to the newer system, and others not.
      • UPDATE: The development version of {httr2} has functionality to help with this quite a lot, thankfully! I’m skipping this milestone while that functionality stabilizes (this was previously 0.3.0).
  • 0.6.0: Expected results.
    • Add response (return value) documentation.
    • Use expected responses to generate better test scaffolds.
    • Potential challenges: Testing the generation of tests might present unique challenges. I’ll need to look into how testthat tests itself.
  • 0.7.0: Error messaging.
    • Add more robust error messaging for non-standard responses.
    • Potential challenges: Mocking cases where things fail can be tricky. Ideally this step will involve pushing the package to a stable 1.0.0, but that will require enough usage to feel confident that the core function definitions are stable.


Install the development version of beekeeper from GitHub:

# install.packages("pak")


Use use_beekeeper() to generate a _beekeeper.yml file, and then generate_pkg() to generate code based on that configuration.

Read vignette("beekeeper") for more details.

The api2r package ’verse

  • {beekeeper} (this package) is intended to help you rapidly create an R package that interfaces with a web API.
  • {nectar} applies an opinionated framework around {httr2}, aimed at making it easy to create standardized API-wrapping packages. Packages generated by {beekeeper} import functions from {nectar}, to avoid the relatively high dependency graph associated with {beeekeeper}.
  • {rapid} converts OpenAPI descriptions of APIs to R objects. These objects are meant to provide a standardized starting point for {beekeeper} (and any future packages that generate R code from API specs, or, eventually, API specs from R code).
  • {anyapi} is intended to aid in the discovery of APIs. Eventually it may also auto-generate functions to interact with a newly discovered API, but that functionality is not yet implemented.

Why “beekeeper”?

A beekeeper is someone who tends to bees, and {beekeeper} is a package that helps you tend to APIs. “Apis” is Latin for “bee”, and is the genus name for honey bees.

In addition to the pun, I hope to eventually include a “hive” of hex logos on this site, with each hex representing an API package that has been “tended” by {beekeeper}.

Code of Conduct

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