get_api_data {bysykkel} | R Documentation |
Get real-time data from the city bike APIs in Norway
Description
get_api_data
gets real-time data on bike availability, stations, and
system from the API for
Please read the API documentation for each City Bike API before using this function.
The real-time data is provided in the GBFS (General Bikeshare Feed Specification) format, which you can read more about on here.
The data is provided according to the Norwegian License for Open Government Data 2.0 NLOD 2.0.
Usage
get_api_data(client_id, data, city, return_df = FALSE)
Arguments
client_id |
A string. The string should represent a client identifier to access the
API. The client identifier must be of the form |
data |
A string. The data that you want to get from the API. The options are "availability", "stations", and "system". |
city |
A string. The city, or city bike service API, that you want to get data from. The options are "Oslo", "Bergen", or "Trondheim". |
return_df |
Either |
Value
If return_df = FALSE
, then the function returns a list
that
contains two elements: a data frame with the
"main" data, and the datetime (POSIX) for the API request. If
return_df = TRUE
, then the function returns only a tibble.
Examples
## Not run:
# Get data on bike "availability"
oslo_api_data <- get_api_data(client_id = "mycompany-myservice",
data = "availability",
city = "Oslo")
# Get data on bike "availability", but return a tibble
oslo_winter_bike <- get_api_data(client_id = "myname-myapp",
data = "availability",
city = "Oslo",
return_df = TRUE)
## End(Not run)