96
96
# ' try(read_api("ABS_C16_T10_SA", datakey = list(regiontype = "DZN")))
97
97
# '
98
98
# ' # If you already have a query url, then use `read_api_url()`
99
- # ' wpi_url <- "https://api. data.abs.gov.au/data/ABS,WPI/all"
99
+ # ' wpi_url <- "https://data.api. abs.gov.au/rest /data/ABS,WPI/all"
100
100
# ' read_api_url(wpi_url)
101
101
# ' }
102
102
# ' @name abs_api
106
106
# ' @rdname abs_api
107
107
read_api_dataflows <- function () {
108
108
check_abs_connection()
109
- r <- httr :: GET(abs_api_url(" dataflow/ABS" ))
109
+ r <- httr :: GET(abs_api_url(" rest/ dataflow/ABS" ))
110
110
r <- httr :: content(r )
111
111
out <- purrr :: map_dfr(r $ references , ~ . [c(" id" , " name" , " version" )])
112
112
names(out ) <- c(" id" , " name" , " version" )
@@ -139,7 +139,8 @@ read_api <- function(id, datakey = NULL, start_period = NULL, end_period = NULL,
139
139
} else {
140
140
k <- " all"
141
141
}
142
- url <- abs_api_url(c(" data" , dataflow , k ), q )
142
+
143
+ url <- abs_api_url(c(" rest" , " data" , dataflow , k ), q )
143
144
144
145
# Fetch data
145
146
df <- abs_api_fetch_data(url )
@@ -167,7 +168,7 @@ read_api_url <- function(url) {
167
168
read_api_datastructure <- function (id ) {
168
169
check_abs_connection()
169
170
170
- r <- httr :: GET(abs_api_url(c(" datastructure " , " ABS" , id , " ?references=codelist " )), httr :: accept_xml())
171
+ r <- httr :: GET(abs_api_url(c(" rest " , " dataflow " , " ABS" , id , " ?references=all " )), httr :: accept_xml())
171
172
httr :: stop_for_status(r )
172
173
r <- httr :: content(r )
173
174
@@ -220,7 +221,7 @@ read_api_datastructure <- function(id) {
220
221
# '
221
222
# ' abs_api_url(c("a", "path"), query = c(nulls = NULL, get = "dropped"))
222
223
abs_api_url <- function (path , query = NULL ) {
223
- out <- paste0(" https://api. data.abs.gov.au/" , paste(path , collapse = " /" ))
224
+ out <- paste0(" https://data.api .abs.gov.au/" , paste(path , collapse = " /" ))
224
225
if (! is.null(query )) {
225
226
query <- paste(names(query ), query , sep = " =" )
226
227
out <- paste0(out , " ?" , paste(query , collapse = " &" ))
@@ -229,7 +230,6 @@ abs_api_url <- function(path, query = NULL) {
229
230
out
230
231
}
231
232
232
-
233
233
# ' Extract dataflow id from url string
234
234
# '
235
235
# ' @param url A url string
@@ -240,13 +240,13 @@ abs_api_url <- function(path, query = NULL) {
240
240
# '
241
241
abs_api_id_from_url <- function (url ) {
242
242
stopifnot(" `url` must be of length 1" = length(url ) == 1 )
243
- if (! grepl(" ^https://api. data.abs.gov.au/data/ABS," , url )) {
243
+ if (! grepl(" ^https://data.api. abs.gov.au/rest /data/ABS," , url )) {
244
244
stop(" `url` is not an ABS query url. Query urls must match regex: \n\t " ,
245
- " '^https://api. data.abs.gov.au/data/ABS,.*'" ,
246
- call. = FALSE
245
+ " '^https://data.api. abs.gov.au/rest /data/ABS,.*'" ,
246
+ call. = FALSE
247
247
)
248
248
}
249
- id <- strsplit(url , " /" )[[1 ]][5 ]
249
+ id <- strsplit(url , " /" )[[1 ]][6 ]
250
250
id <- strsplit(id , " ," )[[1 ]][2 ]
251
251
id
252
252
}
0 commit comments