API examples

All examples requiring access tokens will be denoted as "Bearer " where 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. is the 24-characted hexadecimal used to identify your node.

Simple update

This example updates the description of your device

Yggio API:

curl -sS -X PUT https://staging.yggio.net/api/iotnodes/<device_id> \
-H 'authorization: Bearer <token>' \
-H 'content-type: application/json' \
-d @- <<EOF
{
  "description": "My new description"
}
EOF

NGSI v2

curl -sS -X POST https://staging.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


NGSI v2 Example calls

The following example posts a new entity of the type Room to the Yggio 3 Beta server

curl https://staging.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


This example retrieves an entity with a specific type, in this case "Room"

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


Update the description of an existing node

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


Update values of existing entity

curl -sS -X POST https://ngsi.staging.yggio.net/v2/entities/<id>/attrs -H "Fiware-UserToken: <token>" -H 'Content-Type: application/json' -d @- <<EOF
{"temperature":{"value":28,"type":"Float"},"humidity":{"value":48,"type":"Float"},"lux":{"value":1245,"type":"Float"}}
EOF


Get entities of certain type

curl https://ngsi.staging.yggio.net/v2/entities?type=<type> -H "Fiware-UserToken: <token>"


Get entities that fulfills q query

curl "https://ngsi.staging.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.staging.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.staging.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.staging.yggio.net/v2/subscriptions -H "Fiware-UserToken: <token>"


Filtering devices

GET https://staging.yggio.net.yggio.net/api/iotnodes?matchPattern=%7B"contextMap.Place":"Building1"%7D


Filtering devices

GET https://staging.yggio.net.yggio.net/api/iotnodes?matchPattern=%7B"contextMap.Place":"Building1"%7D