Skip to content

Commit

Permalink
add small pause to limit request rate (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aariq committed Feb 14, 2023
1 parent b455f1e commit 1bde09c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/retrieve_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ retrieve_data <- function(station_id, start_f, time_interval,
endpoint = c("daily", "hourly", "hueto")) {
endpoint <- match.arg(endpoint)
path <- c("v1", "observations", endpoint, station_id, start_f, time_interval)

# TODO: there are probably better ways to do this:
# limit request rate
Sys.sleep(0.2)

res <- httr::GET(base_url, path = path, httr::accept_json())
check_status(res)
data_raw <- httr::content(res, as = "parsed")
Expand Down

0 comments on commit 1bde09c

Please sign in to comment.