Skip to main content

NGSI

This document contains some examples of some common API calls for handling iotnodes with the NGSI v2 API. You can also interact with iotnodes through the regular Yggio API. For more information about the Yggio API, see the Handling Iotnodes section.

All examples requiring access tokens will be denoted as "Bearer <token>" where <token> should be replaced with your own access token.

fiware-userid should be your users id, which can be found in the user profile in the control panel.

<device_id> is the 24-characted hexadecimal used to identify your node.

Create a new entity

In this example we create a new entity of type Room with some attributes.

curl https://public.yggio.net/ngsi/v2/entities -s -S -H "Fiware-UserToken: $TKN" -H 'Content-Type: application/json' -d @- <<EOF
{"id":"myRoom","type":"Room","temperature":{"value":23,"type":"Float"},"humidity":{"value":45,"type":"Integer"}}
EOF

Update a entity

In this example we update the description of the entity.

curl -sS -X POST https://public.yggio.net/ngsi/v2/entities/<device_id>/attrs?type=Device \
-H 'authorization: Fiware-UserToken <token>' \
-H 'content-type: application/json' \
-H 'fiware-service: yggio' \
-H 'fiware-servicepath: /' \
-H 'fiware-userid: <userid>' \
-d @- <<EOF
{
"description": "My new description"
}
EOF

Fetch entities

In this example we fetch all entities of a specific type, in this case Room.

curl https://public.yggio.net/ngsi/v2/entities?type=Room -H "Fiware-UserToken: $TKN"

In this example we show how to fetch entities that matches a specific "q query".

curl "https://ngsi.public.yggio.net/v2/entities?type=Device&q=<root key>.<key><condition>%27<value>%27" -H "Fiware-UserToken: <token>" -H "fiware-service: yggio" -H "fiware-servicepath: /"

Full example:
curl "https://ngsi.public.yggio.net/v2/entities?type=Device&q=contextMap.Place %3D%3D%%27Building1%27" -H "Fiware-UserToken: <token>" -H "fiware-service: yggio" -H "fiware-servicepath: /"

Create an NGSI subscription

curl -sS -X POST https://ngsi.public.yggio.net/v2/subscriptions -H "Fiware-UserToken: <token>" -H 'Content-Type: application/json' -d @- <<EOF
{
"description": "Initiate NSGI subscription",
"subject": {
"entities": [
{
"id": <id>,
"type": <type>
}]},
"notification": {
"http": {
"url": <url>
}}}
EOF

List NGSI subscriptions

curl https://ngsi.public.yggio.net/v2/subscriptions -H "Fiware-UserToken: <token>"