R client for ausdata.io
R researchers want a tibble, not a list of lists. The snippet below uses httr2 to call the endpoint and jsonlite to flatten the data array into a tibble, ready for dplyr.
No CRAN package yet. The httr2 helper above is the canonical client.
Install
Shell
install.packages(c("httr2", "jsonlite", "tibble"))Canonical client
R
library(httr2)
library(jsonlite)
library(tibble)
ausdata <- function(path, ...) {
request("https://api.ausdata.io") |>
req_url_path_append(path) |>
req_url_query(...) |>
req_headers(Authorization = paste("Bearer", Sys.getenv("AUSDATA_KEY"))) |>
req_perform() |>
resp_body_json(simplifyVector = TRUE)
}Use it
R
snap <- ausdata("/v1/economic-dashboard")
as_tibble(snap$data)Notes
- .Set AUSDATA_KEY in .Renviron. Restart R to pick it up.
- .simplifyVector = TRUE turns the JSON array into a data.frame ready for as_tibble.
- .Cache responses with memoise() if you call the same endpoint inside a knit loop.
Other SDKs
Get a key and call your first endpoint
500 free calls per month. No credit card.
Get a free API key