| Title: | Read Data from the vespa-db Database |
|---|---|
| Description: | Read data from the vespa-db database hosted at https://nesten.vespawatch.be. |
| Authors: | Pieter Huybrechts [aut, cre] (ORCID: <https://orcid.org/0000-0002-6658-6062>, affiliation: Research Institute for Nature and Forest (INBO)), Sander Devisscher [aut] (ORCID: <https://orcid.org/0000-0003-2015-5731>, affiliation: Research Institute for Nature and Forest (INBO)) |
| Maintainer: | Pieter Huybrechts <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0.9000 |
| Built: | 2026-10-09 10:26:45 UTC |
| Source: | https://github.com/inbo/vespadb |
Fetches the result from a given URL with optional query parameters and authentication.
fetch_result(url, .query_params = list(), .auth = NULL, return_request = FALSE)fetch_result(url, .query_params = list(), .auth = NULL, return_request = FALSE)
url |
The API endpoint to fetch the result from. |
.query_params |
Optional query parameters to include in the request. |
.auth |
Optional path to authentication cookie to use. |
return_request |
If TRUE, the function returns the request object instead of the response. |
The response object or the request object if return_request is TRUE.
## Not run: # Fetch result from a URL fetch_result("https://uat-db.vespawatch.be/observations/30608") # Fetch result with query parameters fetch_result("https://uat-db.vespawatch.be/observations/", .query_params = list(municipality_id = 215)) # Return request object instead of response fetch_result("https://uat-db.vespawatch.be/observations/30608", return_request = TRUE) ## End(Not run)## Not run: # Fetch result from a URL fetch_result("https://uat-db.vespawatch.be/observations/30608") # Fetch result with query parameters fetch_result("https://uat-db.vespawatch.be/observations/", .query_params = list(municipality_id = 215)) # Return request object instead of response fetch_result("https://uat-db.vespawatch.be/observations/30608", return_request = TRUE) ## End(Not run)
This function retrieves the field definitions for the vespa-db Observations API schema. This is an overview of the information we have for every record. Not all columns that are in this table are returned in the API endpoints.
get_field_definitions(domain = c("production", "uat"), check_required = TRUE)get_field_definitions(domain = c("production", "uat"), check_required = TRUE)
domain |
The domain to query. Either "uat" for the testing instance, or "prod" for the production instance. |
check_required |
Logical indicating whether to check if any fields are required. If no required fields are in the definition a warning is returned. |
A tibble with the field definitions.
## Not run: # complete field definitions get_field_definitions("production") ## End(Not run)## Not run: # complete field definitions get_field_definitions("production") ## End(Not run)
get_vespadb_obs()
This function retrieves the parameters that can be used in the
get_vespadb_obs() function. It will return a tibble with the parameters
that can be used in the query.
get_observation_parameters(domain = c("production", "uat"), ...)get_observation_parameters(domain = c("production", "uat"), ...)
domain |
The domain to login to. Default is "uat" for the UAT environment. |
... |
Additional parameters to internal methods. |
A tibble with the parameters that can be used in the
get_vespadb_obs() function.
get_observation_parameters()get_observation_parameters()
This function will return you the allowed parameters for a given API call. By
default it will return all fields allowed in a get_vespadb_obs() query.
get_params( path = "observations", request_type = "get", domain = c("production", "uat") )get_params( path = "observations", request_type = "get", domain = c("production", "uat") )
path |
The endpoint to get the parameters for, only GET endpoints are supported. |
request_type |
The type of request to get the parameters for, either "get" or "post". |
domain |
The domain to login to. Default is "uat" for the UAT environment. |
A tibble with the parameters for the given path.
get_params()get_params()
This function returns all observations from the VespaDB API export.
get_vespadb_export(domain = c("production", "uat"))get_vespadb_export(domain = c("production", "uat"))
domain |
The domain to query. Either "uat" for the testing instance, or "prod" for the production instance. |
Daily around 4 AM a export is created from the VespaDB API and stored in S3. This function retrieves the latest export from S3 and returns it as a tibble.
This function is useful for getting a snapshot of the data in the VespaDB API or for getting a large amount of data.
A tibble with the observations from the VespaDB API export.
## Not run: # Get the latest export from the VespaDB API get_vespadb_export() # Get the latest export from the VespaDB API in the production instance get_vespadb_export(domain = "production") ## End(Not run)## Not run: # Get the latest export from the VespaDB API get_vespadb_export() # Get the latest export from the VespaDB API in the production instance get_vespadb_export(domain = "production") ## End(Not run)
Query the vespa-db api to get observations
get_vespadb_obs(..., auth = NULL, domain = c("production", "uat"))get_vespadb_obs(..., auth = NULL, domain = c("production", "uat"))
... |
< |
auth |
Character. Path to the authentication cookie to use. By default a
request without authentication is placed (public data only). The
authentication cookie can be created using |
domain |
Character. The domain to login to. Default is "uat" for the UAT environment. |
Extra query parameters are supported according to the Observation model. More
information on the allowed parameters can be fetched via
get_field_definitions().
This function already handles paging, so supplying a page as a parameter is
not allowed. For a more low level function to fetch results see
fetch_result().
A tibble with the observations from the VespaDB API.
## Not run: # All public records get_vespadb_obs() # Public records from Ghent get_vespadb_obs(municipality_id = 215) # Public and private information from Ghent, only ANB plots get_vespadb_obs( municipality_id = 215, anb = "true", auth = login_vespadb() ) ## End(Not run)## Not run: # All public records get_vespadb_obs() # Public records from Ghent get_vespadb_obs(municipality_id = 215) # Public and private information from Ghent, only ANB plots get_vespadb_obs( municipality_id = 215, anb = "true", auth = login_vespadb() ) ## End(Not run)
This function allows you to login to the API and returns the required csrftoken needed to fetch information that is not publicly available.
login_vespadb(username, password, domain = c("production", "uat"))login_vespadb(username, password, domain = c("production", "uat"))
username |
The username to login with, if not provided it will
be read from the environment variable |
password |
The password to login with, if not provided it will
be read from the environment variable |
domain |
The domain to login to. Default is "production" for the UAT environment. |
The path to an authentication cookie.
## Not run: get_vespadb_obs( municipality = 215, auth = login_vespadb( "username", "password" ) ) ## End(Not run)## Not run: get_vespadb_obs( municipality = 215, auth = login_vespadb( "username", "password" ) ) ## End(Not run)
This function either returns a complete overview of all municipality ids. Or if one or more municipalities are passed, the id's for these municipalities.
municipalities(municipalities = NULL, domain = c("production", "uat"))municipalities(municipalities = NULL, domain = c("production", "uat"))
municipalities |
(Optional) A character vector of municipality names. If this is not provided, all municipalities will be returned as a tibble with their ids. |
domain |
Character. The domain to login to. Default is "uat" for the UAT environment. |
Either a numeric vector of ids, or if no argument is passed, a tibble with all municipalities and their id.
municipalities("Gent") municipalities(c("Gent", "Kortrijk")) municipalities()municipalities("Gent") municipalities(c("Gent", "Kortrijk")) municipalities()