This vignette will show how to set up tscr via environment variables to connect to either the TSC API, or the TSC UAT API (to test write operations on disposable data).

Settings via environment variables

Run usethis::edit_r_environ() to open your .Renviron file. Paste the following code into the file with your own TSC credentials, then restart your R session (Ctrl+Shift+F10 in RStudio) to apply the changes.

tscr will use these environment variables as defaults for the TSC API location and authentication.

TSC users can find their API Token on their “Profile” page. The API Token is a character string starting with “Token”. While TSC (Production) contains the production data, we use the User Acceptance Testing (UAT) instance at TSC UAT to test this package’s read and write functionality. Users can also use TSC UAT to test their own data uploads.

TSC_API_URL="https://tsc.dbca.wa.gov.au/api/1/"
TSC_API_TOKEN="Token xxx"
TSC_TEST_API_URL="https://tsc-uat.dbca.wa.gov.au/api/1/"
TSC_TEST_API_TOKEN="Token xxx"
TSC_VERBOSE=TRUE

At a minimum, tscr needs TSC_API_TOKEN set. The other settings should work with defaults, but tscr nevertheless offers setters and getters.

Settings via setup

To jump between TSC instances, you can set up tscr via tscr::tscr_setup().

tscr::tsc_setup(
  api_url = "https://tsc.dbca.wa.gov.au/api/1/",
  api_token = "Token xxxx",
  test_api_url = "https://tsc-uat.dbca.wa.gov.au/api/1/",
  test_api_token = "Token xxxx",
  verbose = TRUE
)
# typically followed by several functions requiring above settings

Settings via parameters

You can run individual functions with specific settings as parameters. The tests set the TSC UAT credentials explicitly this way.

tscr::tsc_GET(
  serializer = "area",
  api_url = "https://tsc.dbca.wa.gov.au/api/1/",
  api_token = "Token xxxx",
  test_api_url = "https://tsc-uat.dbca.wa.gov.au/api/1/",
  test_api_token = "Token xxxx",
  verbose = TRUE
)