Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/52north/edis-lib


https://github.com/52north/edis-lib

Last synced: 6 days ago
JSON representation

Awesome Lists containing this project

README

        

# edis-lib

Library to consume the DICT-API and the [Pegelonline REST-API](https://www.pegelonline.wsv.de/webservice/guideRestapi)

## Build libs

To get a packaged build of the edis lib use `pnpm build`. After that you got an npm package in both folders `browser` and `node`.

## Getting started with the lib

``` typescript
const edis = new Edis({
dictApiUrl: 'http://localhost:3000', // optional, example is for local development
mqttCredentials: {
username: '...', // needed for a secured mqtt broker
password: '...', // needed for a secured mqtt broker
},
});

// request all stations
edis.getStations().subscribe({
next: (stations) => {
if (stations.length >= 1) {
// select the first station of the list
const station = stations[0];
// get all timeseries of the station
const ts = station.getTimeSeries();
if (ts.length >= 1) {
// get first timeseries
const timeseries = ts[0];
// get timeseriesData for the last 10 hours
timeseries.getTimeSeriesData('PT10H').subscribe((data) => console.log(data));
// get characteristicValues for the given timeseries
timeseries.getCharacteristicValues().subscribe((values) => console.log(values));
// get current timeseries data by internally subscribing to the corresponding mqtt topic for this time series
timeseries.getCurrentTimeSeriesData().subscribe((data) => console.log(data));
}
}
},
});
```