Lille Ø - Plugins and the new Signal K REST API...
Plugins and the new Signal K REST APIs... what's the correct way to interact? For dealing with information in Signal K paths, you can do
app.getSelfPath
and app.putSelfPath
. However, to query something like the new Weather API, is the right way to do a fetch()
inside the plugin?9 Replies
As an example, I was thinking signalk-meshtastic could poll for weather warnings and send them onwards via Meshtastic
The weather plugin does not currently expose any methods to plugins (via the ServerAPI) like other APIs do (e.g. resources, autopilot).
Depending on the plugin (and the weather service) warnings are sent as notifications….
signalk-openweather-provider
plugin does this.
fetch()
is ok to use but we can also look at exposing methods to the ServerAPI.That would be useful. But if there's a notification, that also works fine. Do you have an example of the data structure?
It's in the OpenAPI doc (WeatherWrningDataModel)
i think we should definitely expose the APIs for other plugins to consume
if i take my wip HistoryAPI provider implementation as an example: so a plugin would implement & register itself as a HistoryProvider
and the
app
object that is exposed to plugins could implement the same interface (or would it be better to have an app property like history: HistoryProvider
)
just thinking out loud here - @AdrianP have you thought about this in any more detail?GitHub
signalk-server/packages/server-api/src/history.ts at d3e1953f93f9e2...
An implementation of a Signal K central server for boats. - SignalK/signalk-server
Both
resources
and course
APIs expose methods to the server for use by plugins.
My preference would be to use an app.[apiName].method()
approach.... thoughts?
I will expose weather api methods using the agreed approach.So there would be something like
app.weather.getForecastsDaily()
method?I’d expect methods aligning to the api operations:
- getObservations(…)
- getForecasts(…)
- getWarnings(…)
@Lille Ø FYI created PR to expose these methods to plugins... https://github.com/SignalK/signalk-server/pull/2110