source("R/setup.R")$value

Instructions for the first-time use of the STATcube REST API. See also the wingarc docs for the vendor documentation on API keys.

Adding an API key

In order to use the REST API of STATcube it is necessary to provide an API key. This means that you will need a subscription for STATcube. Subscribed users will automatically get access to the STATcube API. The API key can be displayed under the account preferences ^[The link to the preferences will only work if you are already logged in into STATcube] of STATcube.

img_uri <- knitr::image_uri("img/preferences-menu.png")

To make the key available for r STATcubeR, use the function sc_key_set(). Replace "XXXX" with your key.

sc_key_set("XXXX")
sc_key_set(sc_key(), test = FALSE)

As suggested by the code output, the key will be used for any API requests that happen in the same R session. You can set the key persistently by modifying .Renviron. This can be done easily with usethis::edit_r_environ().

By default, sc_key_set() will perform a test request to verify that the key is valid and throw an error if the test request is unsuccessful.

sc_key_set('wrong key')
#> Error in sc_key_set("wrong key") : The key could not be verified
#> Run sc_last_error() or read the online documentation for more details

Next Steps

See the r ticle('sc_table') to see how tables can be defined in the STATcube GUI and imported into R. Alternatively, import a saved table by following the r ticle('sc_table_saved'). For more advanced usage of r STATcubeR, see the r ticle('sc_schema') and r ticle('sc_table_custom')

For employees of Statistics Austria

Employees should use one of our internal STATcube servers for API requests. Please refer to the following internal confluence documentation for more information on how to get started:

https://statportal.statistik.local/statistik.at/confluence/x/uDiTAQ



statistikat/STATcubeR documentation built on Dec. 3, 2024, 8:04 p.m.