api_key: Get and set your openFDA API keys

set_api_keyR Documentation

Get and set your openFDA API keys

Description

Get and set your openFDA API keys

Usage

set_api_key(api_key)

get_api_key()

Arguments

api_key

A single-length character vector with your openFDA API key. You can generate an API key on the FDA website.

Value

A single length character vector with your API key. For set_api_key(), this is returned invisibly.

For get_api_key(), an error will be thrown if no key has been set.

Note

To permanently set the API key for a given project, set OPENFDA_TOKEN in .Renviron.

Examples

# Set your openFDA API key with `set_api_key()`
api_key <- "example_api_key"
set_api_key(api_key)

# Retrieve it with `get_api_key()`
get_api_key()

# An error will be thrown if your API key is an empty string.
set_api_key("")

try(get_api_key())

openFDA documentation built on Oct. 18, 2024, 5:12 p.m.