Description Usage Arguments Value Examples
GETs data from a Civic API endpoint
1 | get_civic_api(url, verbose)
|
url |
the URL to GET |
verbose |
print status info |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ## Not run:
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)
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.