Create a configuration file for a package to use beekeeper. The configuration file tracks information that will be used for generation of other functions, and the timestamp when the configuration was last updated or used.
Usage
use_beekeeper(
x,
api_abbr,
...,
pkg_dir = ".",
config_filename = "_beekeeper.yml",
rapid_filename = "_beekeeper_rapid.rds"
)Arguments
- x
An object to use to define the configuration. It must be translatable to a
rapid::class_rapid()object byrapid::as_rapid(). Usually this will be a url pointing to an OpenAPI document, or a list generated by reading such a document.- api_abbr
(
character(1)) A short (about 2-5 letter) abbreviation for the API, for use in function names and environment variables.- ...
These dots are for future extensions and must be empty.
- pkg_dir
(
character(1)orfs_path) The directory containing package files.- config_filename
(
character(1)orfs_path) The path to a beekeeper yaml config file (relative to the package root).- rapid_filename
(
character(1)orfs_path) The path to the R API definition (rapid) file (relative to the package root).
Value
(character(1), invisibly) The path to the configuration file. The
config file is written as a side effect of this function. The rapid object
is also written, and the path to that file (relative to pkg_dir) is saved
in the config file.
Examples
# Set up an empty package.
pkg_dir <- unclass(fs::path_norm(withr::local_tempdir()))
usethis::create_package(pkg_dir, open = FALSE, check_name = FALSE)
#> ✔ Creating /tmp/RtmpYHNcPJ/file449377c35c9/.
#> ✔ Setting active project to "/tmp/RtmpYHNcPJ/file449377c35c9".
#> ✔ Creating R/.
#> ✔ Writing DESCRIPTION.
#> Package: file449377c35c9
#> Title: What the Package Does (One Line, Title Case)
#> Version: 0.0.0.9000
#> Authors@R (parsed):
#> * First Last <first.last@example.com> [aut, cre]
#> Description: What the package does (one paragraph).
#> License: `use_mit_license()`, `use_gpl3_license()` or friends to
#> pick a license
#> Encoding: UTF-8
#> Roxygen: list(markdown = TRUE)
#> RoxygenNote: 8.0.0
#> ✔ Writing NAMESPACE.
#> ✔ Setting active project to "/__w/beekeeper/beekeeper".
usethis::local_project(pkg_dir)
#> ✔ Setting active project to "/tmp/RtmpYHNcPJ/file449377c35c9".
#> ✔ Setting active project to "/__w/beekeeper/beekeeper".
# Read an api definition. This could also simply be a URL to such a
# definition.
api_definition <- read_api_definition(fs::path_package("beekeeper", "guru"))
# Set up the package to use beekeeper with that definition.
use_beekeeper(api_definition, "guru")
#> ✔ Setting active project to "/__w/beekeeper/beekeeper".
#> ✔ Setting active project to "/__w/beekeeper/beekeeper".
read_config()
#> $api_title
#> [1] "APIs.guru"
#>
#> $api_abbr
#> [1] "guru"
#>
#> $api_version
#> [1] "2.2.0"
#>
#> $rapid_filename
#> [1] "_beekeeper_rapid.rds"
#>
#> $updated_on
#> [1] "2026-05-20 14:17:17 UTC"
#>
all.equal(read_api_definition(), api_definition)
#> [1] TRUE
# Clean up.
withr::deferred_run()
#> No deferred expressions to run