An R client for Weatherlink v2 API
library("rweatherlink")The api key and api secret are read by default from environmental
variables WL_API_KEY and WL_API_SECRET, but you can provide them
also in every function call using the api_key= and api_secret=
arguments.
For each endpoint we provide convenience wrappers, like
wl_stations()The full list of endpoints wrappers is:
wl_stations()for/stations&stations/{station-ids}endpointswl_nodes()for/nodes&nodes/{nodes-ids}endpointswl_sensors()for/sensors&sensors/{sensor-ids}endpointswl_sensor_activity()for/sensor-activity&sensor-activity/{sensor-ids}endpointswl_sensor_catalog()for/sensor-catalogendpointwl_current()for/current/{station-id}endpointwl_historic()for/historic/{station-id}endpoint
For each of the listed functions (except wl_sensor_catalog()) we
provide (opinionated) convenience parsers, that parse the return value
into a nice data.frame. Columns with UTC-dates for timestamps are
added, as well as elevation in meters.
The generic function for all objects is wl_parse()
wl_stations() %>% wl_parse()
wl_sensors() %>% wl_parse()These parsers are in an experimental stage.
wl_historic() needs unix-timestamps as input for start and end. These
can be easily generated from POSIXct objects, e.g.
as.integer(Sys.time())
#> [1] 1608050438gives the timestamp of the current time.
wl_request() is the workhorse of this package.
With it you can query every API endpoint, e.g.
wl_request(endpoint = "stations")It takes also care of creating the correct api-signature via HMAC, which
us handled by wl_params().
To run the full test suite set valid environmental variables
WL_API_KEY and WL_API_SECRET and run devtools::test().
Note, that for some tests more than one stations is needed.
Currently, code coverage is very high. wl_nodes is not well covered by the unit tests.