Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inbo/etnservice
R package to serve data from the European Tracking Network over a restful api
https://github.com/inbo/etnservice
animal-movement animal-tracking api biologging data-access fish lifewatch opencpu oscibio r r-package rstats
Last synced: about 2 months ago
JSON representation
R package to serve data from the European Tracking Network over a restful api
- Host: GitHub
- URL: https://github.com/inbo/etnservice
- Owner: inbo
- License: other
- Created: 2022-12-09T15:32:47.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-06T13:26:32.000Z (about 2 months ago)
- Last Synced: 2024-11-06T13:34:09.292Z (about 2 months ago)
- Topics: animal-movement, animal-tracking, api, biologging, data-access, fish, lifewatch, opencpu, oscibio, r, r-package, rstats
- Language: R
- Homepage:
- Size: 320 KB
- Stars: 1
- Watchers: 6
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# etnservice
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![R-CMD-check](https://github.com/inbo/etnservice/actions/workflows/R-CMD-check-lite.yaml/badge.svg)](https://github.com/inbo/etnservice/actions/workflows/R-CMD-check-lite.yaml)The goal of etnservice is to to serve data from the European Tracking Network as a restful API.
## About/Data Policy
Etn provides functionality to access data from the [European Tracking
Network (ETN)](http://www.lifewatch.be/etn/) database hosted by the
Flanders Marine Institute (VLIZ) as part of the Flemish contribution to
LifeWatch. ETN data is subject to the [ETN data
policy](http://www.lifewatch.be/etn/assets/docs/ETN-DataPolicy.pdf) and
can be:- restricted: under moratorium and only accessible to logged-in data
owners/collaborators
- unrestricted: publicly accessible without login and routinely
published to international biodiversity facilitiesThe ETN infrastructure currently requires the package to be run within
the [LifeWatch.be RStudio server](http://rstudio.lifewatch.be/), which
is password protected. A login can be requested at
.## Installation
etnservice needs direct access to the [ETN](https://lifewatch.be/etn/) database, thus a local install will not function without a copy of this database.
You can install the development version of etnservice from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("inbo/etnservice")
```## How to use the API
This is a basic example which shows you how adress the API directly:
```{r example, eval = FALSE}
library(httr) # to talk to the internet
library(magrittr) # to use pipes
library(jsonlite) # to work with JSON files
library(askpass) # to safly enter a password in R# To access the ETN database, we need a login (username + password). We'll ask
# for the password dynamically because that's safer than storing it as an object
username <- ""
# All functions can be adressed directly in the URL
endpoint <- "https://opencpu.lifewatch.be/library/etn/R/list_animal_ids"
# Request the result of the function to be a json, and put in a request
response <-
httr::POST(paste(endpoint, "json", sep = "/"),
body = list(
credentials = glue::glue('list(username = "{username}", password = "{askpass::askpass()}")')
)
)
# Take the response of the server, and convert it into an R object we can use
response %>%
httr::content(as = "text", encoding = "UTF-8") %>%
jsonlite::fromJSON(simplifyVector = TRUE)```
However, a fork of the [etn package](https://github.com/inbo/etn) is currently in development that will allow you to do this using built in functions.
Another example of the same request as above, but now using [curl](https://curl.se/):
```{bash,eval = FALSE}
#! /bin/bash
curl --location --request POST 'https://opencpu.lifewatch.be/library/etnservice/R/list_animal_ids/json' \
--header 'Content-Type: application/json' \
--header 'Cookie: vliz_webc=vliz_webc2' \
--data-raw '{
"credentials": {
"username": "",
"password": ""
}
}'
```