General description of the RESTful-API interface (FWE-API 2).
In this section, the following procedures are explained:
If you are interested in getting access to the freshwaterecology.info database via API, please follow the next two steps.
NOTE: freshwaterecology.info is a joint effort of scientists for scientists and other interested individuals. The content of the database is meant to be freely available. It is therefore not permitted to integrate the API into commercial software, use the data provided by the API for commercial purposes or use it to build a similar website. Further, the data and the database have to be cited in any product that uses them.
To create API requests in R, two libraries are required that provide the http and json functionality.
If the two libraries ("httr", "jsonlite") are not yet available in the R-Console or RStudio, they can be installed using install.package().
R-Console:
>install.packages(c("httr", "jsonlite"))
R-Console:
>library(httr)
>res = httr::GET("https://www.freshwaterecology.info/fweapi2/v1/status")
>cat(content(res, 'text', encode = "UTF-8"))
R-Console:
>library(httr)
>headers = c(
'Content-Type' = 'application/json'
)
>body = '{
"apikey": "your_apikey"
}';
>res = httr::POST("https://www.freshwaterecology.info/fweapi2/v1/status", body = body, add_headers(headers))
>cat(content(res, 'text', encode = "UTF-8"))
R-Console:
>library(httr)
>res = httr::GET("https://www.freshwaterecology.info/fweapi2/v1/getecoparamlist")
>cat(content(res, 'text', encode = "UTF-8"))
R-Console:
>library(httr)
>headers = c(
'Authorization' = 'Bearer your_token',
'Content-Type' = 'application/json'
)
>body = '{
"organismgroup": "fi",
"taxonname": "",
"genus": "Salmo"
}';
>res = httr::POST("https://www.freshwaterecology.info/fweapi2/v1/query", body = body, add_headers(headers))
>cat(content(res, 'text', encode = "UTF-8"))