--- title: "How to handle the API key in public and private codes." output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{How to handle the API key in public and private codes.} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", eval = identical(Sys.getenv("NOT_CRAN"), "true") ) ``` ```{r setup} library(fwtraits) ``` ## Steps in securing the API key. * STEP 1: Acquire the API key, the user can follow the steps elucidated in **`fw_be4ustart()`** function. * STEP 2: Edit the .Renviron file by running **`fw_setapikey()`**. * STEP 3: If the .Renviron window opens, please type in **API_KEY = "9f7be425-e099-11ee--.............."** * STEP 4: Save and restart the R session. * STEP 5: The key will be ready for use and will not required to be provided anywhere within the codes thereafter. * STEPT 6: When you test with the codes, a welcome message will be printed before data is retrieved. ### Test if the API key is well saved ```{r} migration <- fw_fetchdata(data = 'Abramis brama', organismgroup = 'fi', ecoparams = 'migration', cachefolder = 'cache', warn = TRUE, inform = TRUE, details = TRUE)#the species spelling is checked #or use the fw_keyload() function: which returns a congratulation message ``` ## 3. References 1. Wickham H (2024). _httr2: Perform HTTP Requests and Process the Responses_. R package version 1.0.3, 2. https://httr2.r-lib.org/articles/wrapping-apis.html