sfa_set_api_key: Set your 'SimFin' API key globally

View source: R/sfa_set_api_key.R

sfa_set_api_keyR Documentation

Set your 'SimFin' API key globally

Description

It is highly recommended to set the API key globally as it makes specifying the api_key argument of other ⁠sfa_*⁠ functions obsolete.

There are two ways to set your API key globally:

  1. Provide the API key directly as a string (api_key = "YourApiKey").

  2. Create a system-wide environment variable containing you API key and refer to that (env_var = "YourEnvVar"). How to create a system-wide environment variable depends on your operating system.

The second option is recommended because your R scripts won't contain your API key and it is safe to keep your scripts in an open repository like GitHub.

Usage

sfa_set_api_key(api_key, env_var)

Arguments

api_key

character You API key. Ignored if you specify env_var as well.

env_var

character Name of an environment variable holding you API key, e.g. SIMFIN_API_KEY. Leave empty (NULL, default) if you want to set your API key directly.

Examples

## Not run: 
# set API key directly
sfa_set_api_key(api_key = "YourApiKey")

# set API key via environment variable
# (this assumes you already created an environment variable called
# 'SIMFIN_API_KEY' which contains you API key)
sfa_set_api_key(env_var = "SIMFIN_API_KEY")

## End(Not run)

simfinapi documentation built on April 14, 2023, 12:27 a.m.