Metadata via api 2.11
hi, I'm working a little bit of an experiment and I am wondering if it's still possible to add custom meter data keys via API in the version 2.11? For example I would not like to use the existing one such as description et cetera I would also like to add for example equipment key as a another key with a value after.
example
{
"equipment": "Engine_1"
}
can I still use the API to achieve this? I've tried round a lot but get some errors.
33 Replies
Sorry i don’t understand what you are trying to do, please explain more, with examples
I will try to explain
I am trying to set metadata of a path using the put API
/signalk/v1/api/vessels/self/' + item.fullKey + '/meta
In older version like 1.7 if remeber it was possible to add custom keys as metadata and custom units when adding metadata via API.
example
/meta example metadata Payload for the put request that have used in the past { "units": "knots", "euqipmentTag": "Engine" "serialNumer: "tet12345 } But since i cant ge this to work in 2.11 I was in the ui under browse data it was possible to metadat directly but only under pre defined keys like description etc My question is have the API changed ? and is it still possible to add custom keys under metadata or only using the predefined ones ?
/meta example metadata Payload for the put request that have used in the past { "units": "knots", "euqipmentTag": "Engine" "serialNumer: "tet12345 } But since i cant ge this to work in 2.11 I was in the ui under browse data it was possible to metadat directly but only under pre defined keys like description etc My question is have the API changed ? and is it still possible to add custom keys under metadata or only using the predefined ones ?
Nothing changed.
You can use PUT to update meta data
See the specification for details on how to use PUT
@Scott Bender It is this documentation you refer to? https://signalk.org/specification/1.7.0/doc/put.html
I am trying to get it work i have got so far that i get only 202 response Pending but noting updated
Are there any more documentation how the metadata should look like? in the payload
yes, that's the doc
you will get Pending response from that
once its done you should see your changes in baseDeltas.json ?
here's the code from where the admin ui does it:
Also, in the pending reponse, there is a url you can call to get the final status and see if there were any errors
The issue is that i dont have access ot the setting files, i need the one i am doing the study project with if we reach the file since we are running it in docker so i cant see it. Thanks for the exmaple. is the meta after value the stringified json object? like this but stringified "meta": {
"discipline": "Naivgation",
"key": "Position.Longitude",
"topic": "Position.Longitude"
},
no "meta"
the body should look like:
and note that you will be overwriting any eisting meta this way
I think... actually not sure about that
I get this in return but there is no meta data nor when i use the api or in ui {
"state": "COMPLETED",
"requestId": "e8392c1b-60c4-417d-a4f5-9ef444d0382e",
"statusCode": 200,
"href": "/signalk/v1/requests/e8392c1b-60c4-417d-a4f5-9ef444d0382e",
"user": "admin"
}
you changed to not include "meta" in the body?
yes
what the exact path you are PUTing to?
the ui won't show that meta data
or will it... let me check
this is my strinfied value.
Do i need to give source key ?
no, you don't need source
In the old 1.7 it showed up
This is my stringified payload "{"value":{"discipline":"Naivgation","key":"Position.Longitude","topic":"Position.Longitude"}}"
looks good
the ui now only shows "known" meta values
which I would love to fix
I'll put that on my list...
Sounds good but i sthould still be possible to store it and return it in the api call?
yes
what's the path you are PUTing too? and what API are you calling to get the meta?
let me do a quick test...
works for me:
http://signalk:3000/signalk/v1/api/vessels/self/navigation/position/meta
same but with get
works for me
i am thinking if there could be some permissions issues with the file
you should get an error from the PUT request in that case
I can double check that...
that works actually then i had a little special path that where it did not work
yep, I get a failure if there are permission issues
it works but i want make it work on this path Machinery.SteeringGear.1.Pump.2.State
for some reason i got it to work now. I restarted signalk then it worked better
thanks for all help
odd
ur welcome
Just from a courious question, how many data points / paths do you think a singalk can handle at second level?
really hard to give a number because it's going to be about memory and CPU
I have 700+ paths on my boat
and recording it all in influxdb, this is on a 16G pi 4, no performance issues
that is cool
We are doing a research project conneting a large ship simulator which have around 1800 signals to prove that the maritime industry would benift of apis
should be able to handle it fine given decent hardware
Yes we will see, thanks for the help we continue tommorow
Please share more about your project later. And i am also interested in your take on apis in this field