GETs data from a Civic API endpoint

get_civic_api(url, verbose)

Arguments

url

the URL to GET

verbose

print status info

Value

a list of two items

  • status_code integer: the HTTP status code (200 for success)

  • response: if status_code == 200, the JSON object from the API; otherwise, the raw text response.

Examples

if (FALSE) { url_base <- "http://service.civicpdx.org/transportation2019/v1/toad" endpoint <- "busPassengerStops" query <- "?limit=10000&lines=10,14&stops=3637,3641,3633&time_range=9,10&service_key=W" url <- paste(url_base, endpoint, query, sep = "/") print(url) response <- rcivicapi::get_civic_api(url, verbose = TRUE) if (response[["status_code"]] == 200) { View(response[["data"]][["results"]][["features"]]) } else { print(response) } }