Title: | Client for the 'FieldClimate' API |
---|---|
Description: | Provides functionality to interact with the 'FieldClimate' API <https://api.fieldclimate.com/v2/docs/>. |
Authors: | Eduard Szöcs [aut, cre], BASF SE [cph] |
Maintainer: | Eduard Szöcs <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2024-12-22 06:32:57 UTC |
Source: | CRAN |
Read user information
List of user devices.
Get station information
Get min and max date of device data availability
Getdata between specified time periods.
fc_get_user(...) fc_get_user_stations(...) fc_get_station(station_id = NULL, ...) fc_get_data(station_id = NULL, ...) fc_get_data_range( station_id = NULL, data_group = c("raw", "hourly", "daily", "monthly"), from = NULL, to = NULL, ... )
fc_get_user(...) fc_get_user_stations(...) fc_get_station(station_id = NULL, ...) fc_get_data(station_id = NULL, ...) fc_get_data_range( station_id = NULL, data_group = c("raw", "hourly", "daily", "monthly"), from = NULL, to = NULL, ... )
... |
additional arguments passed to |
station_id |
station id to query |
data_group |
how to group data |
from |
time in unix timestamps since UTC, e.g. via as.integer(as.POSIXct(Sys.time())) |
to |
time in unix timestamps since UTC as.integer(as.POSIXct(Sys.time())) |
a list with user information.
a list with user stations information.
a list with station details.
a list with station metadata.
a list with station data.
## Not run: fc_get_user() ## End(Not run) ## Not run: stations <- fc_get_user_stations() stations ## End(Not run) ## Not run: stations <- fc_get_user_stations() fc_get_station(stations[[1]]$station_name) ## End(Not run) ## Not run: stations <- fc_get_user_stations() fc_get_data(stations[[1]]$station_name) ## End(Not run) ## Not run: stations <- fc_get_user_stations() fc_get_data_range( station_id = stations[[1]]$station_name, data_group = "raw", from = as.integer(as.POSIXct(Sys.time() - 60*60*24)), to = as.integer(as.POSIXct(Sys.time()))) ## End(Not run)
## Not run: fc_get_user() ## End(Not run) ## Not run: stations <- fc_get_user_stations() stations ## End(Not run) ## Not run: stations <- fc_get_user_stations() fc_get_station(stations[[1]]$station_name) ## End(Not run) ## Not run: stations <- fc_get_user_stations() fc_get_data(stations[[1]]$station_name) ## End(Not run) ## Not run: stations <- fc_get_user_stations() fc_get_data_range( station_id = stations[[1]]$station_name, data_group = "raw", from = as.integer(as.POSIXct(Sys.time() - 60*60*24)), to = as.integer(as.POSIXct(Sys.time()))) ## End(Not run)
authentication is done via hmac, see fc_headers()
.
fc_headers( method = c("GET", "PUT", "POST", "DELETE"), path = NULL, public_key = Sys.getenv("FC_PUBLIC_KEY"), private_key = Sys.getenv("FC_PRIVATE_KEY") ) fc_request( method = c("GET", "PUT", "POST", "DELETE"), path = NULL, body = NULL, public_key = Sys.getenv("FC_PUBLIC_KEY"), private_key = Sys.getenv("FC_PRIVATE_KEY"), verbose = FALSE, timeout = 10 )
fc_headers( method = c("GET", "PUT", "POST", "DELETE"), path = NULL, public_key = Sys.getenv("FC_PUBLIC_KEY"), private_key = Sys.getenv("FC_PRIVATE_KEY") ) fc_request( method = c("GET", "PUT", "POST", "DELETE"), path = NULL, body = NULL, public_key = Sys.getenv("FC_PUBLIC_KEY"), private_key = Sys.getenv("FC_PRIVATE_KEY"), verbose = FALSE, timeout = 10 )
method |
request method |
path |
request path (required) |
public_key |
public key.
Read by default from env variable |
private_key |
private key.
Read by default from env variable |
body |
request body named list. Will be passed to |
verbose |
logical, should the request be printed? |
timeout |
number of seconds to wait for a response before giving up. |
an object of type "request" as returned by httr::add_headers()
.
a list with the parsed response.
https://api.fieldclimate.com/v2/docs/#authentication-hmac
fc_headers(path = "/user", public_key = "invalid", private_key = "invalid") ## Not run: fc_request("GET", "/user") ## End(Not run)
fc_headers(path = "/user", public_key = "invalid", private_key = "invalid") ## Not run: fc_request("GET", "/user") ## End(Not run)
parse data into long data.frame
parse stations into data.frame
fc_parse_data(obj) fc_parse_stations(obj)
fc_parse_data(obj) fc_parse_stations(obj)
obj |
stations object as returned by e.g. |
a data.frame with parsed data.
a data.frame with parsed station data.
## Not run: stations <- fc_get_user_stations() obj <- fc_get_data_range( station_id = stations[[1]]$station_name, data_group = "raw", from = as.integer(as.POSIXct(Sys.time() - 60*60*24)), to = as.integer(as.POSIXct(Sys.time()))) fc_parse_data(obj) ## End(Not run) ## Not run: stations <- fc_get_user_stations() fc_parse_stations(stations) ## End(Not run)
## Not run: stations <- fc_get_user_stations() obj <- fc_get_data_range( station_id = stations[[1]]$station_name, data_group = "raw", from = as.integer(as.POSIXct(Sys.time() - 60*60*24)), to = as.integer(as.POSIXct(Sys.time()))) fc_parse_data(obj) ## End(Not run) ## Not run: stations <- fc_get_user_stations() fc_parse_stations(stations) ## End(Not run)
Ping fieldclimate API
fc_ping(timeout = 2)
fc_ping(timeout = 2)
timeout |
number of seconds to wait for a response before giving up. |
a logical whether the API is reachable or not.
## Not run: fc_ping() ## End(Not run)
## Not run: fc_ping() ## End(Not run)
parse a sensor
parse_sensor(sensor)
parse_sensor(sensor)
sensor |
a sensor |
parse a station
parse_station(station)
parse_station(station)
station |
a stations |
parse a timepoint into a long data.frame
parse_timepoint(timepoint)
parse_timepoint(timepoint)
timepoint |
a timepoint |