Getting meta-data on tags, zones and alerts

Getting meta-data on tags, zones and alerts

Tags

The meta-data of tags can be retrieved via the REST API. Only users with one of the following roles can access the tracking REST API:

  • Site creator
  • Site admin
  • Tracking manager

The API authentication token is used for authentication, it can be retrieved on your Profile page on NAO Cloud. Once you have the authentication key, you can make requests against the nao_trackables endpoint.

To get information of all the tags of the site, use the following API:

1GET /api/v2/sites/{siteID}/nao_trackables

Ex:

Request:

1curl -X GET --header 'Accept: application/json' --header 'Authorization: zq8aTQt9dxNVeggqq2shB4Wbydabc' 'https://www.nao-cloud.com/api/v2/sites/221/nao_trackables'

Response:

1{
2  "nao_trackables":[
3    {
4      "id":249,
5      "name":"A2",
6      "kind":"Asset",
7      "tracking_id":"092353",
8      "loc_updated_at":"2018-04-06T14:05:29Z",
9      "color":"#0ef047",
10      "category":"Test",
11      "mac_address":"11:22:33:44:55:66",
12      "adv_id_full":"iBeacon@B233860B5F9D44EFB657C2966D89BBFB:8000:100",
13      "new_batteries_at": "2018-05-01T00:00:00Z",
14      "estimated_end_of_life": "2023-05-01T00:00:00Z"
15    }
16  ]
17}

Possible optional options:

  • ids: list of IDs, separated by comma (,)
  • tracking_ids:list of Tracking IDs, separated by comma (,)
  • categories: list of categories, separated by comma (,)

Ex:

Request:

1curl -X GET --header 'Accept: application/json' --header 'Authorization: zq8aTQt9dxNVeggqq2shB4Wbydabc' 'https://www.nao-cloud.com/api/v2/sites/221/nao_trackables?ids=249,250'

 

Tag filtering

The REST API allows filter using the following attributes: tracking_id, is_active, category, name, battery. To filter, please add the following parameter filter[<attribute_name>_<ransack_matcher>]. The most used ransack machers are eq (equals) and in (match any values in array). Refer to Ransack for more matchers.

To get tags with a given tracking ID (MAC address), add the following parameter filter[tracking_id_eq]=<tracking_id>

1curl --globoff -X GET --header 'Accept: application/vnd.api+json' --header 'Authorization: zq8aTQt9dxNVeggqq2shB4Wbydabc' "https://www.nao-cloud.com/api/v2/sites/221/nao_trackables?filter[tracking_id_eq]=98:7B:F3:2D:68:20"
To get tags with in a list of  given tracking IDs (MAC addresses), add the following parameter filter[tracking_id_in][]=<tracking_id_1>&filter[tracking_id_in][]=<tracking_id_2>
1curl --globoff -X GET --header 'Accept: application/vnd.api+json' --header 'Authorization: zq8aTQt9dxNVeggqq2shB4Wbydabc' "https://www.nao-cloud.com/api/v2/sites/221/nao_trackables?filter[tracking_id_in][]=98:7B:F3:2D:68:20&filter[tracking_id_in][]=04:A3:16:02:54:C7"

To get tags with a given name, add the following parameter filter[name_eq]=<name>

1curl --globoff -X GET --header 'Accept: application/vnd.api+json' --header 'Authorization: zq8aTQt9dxNVeggqq2shB4Wbydabc' "https://www.nao-cloud.com/api/v2/sites/221/nao_trackables?filter[name_eq]=A3"

If there are no conflict between the tracking_id and the name, the filter[tracking_id_or_name_in]=<tracking_id>,<name> parameter can be used.

1curl --globoff -X GET --header 'Accept: application/vnd.api+json' --header 'Authorization: xxx' 'https://www.nao-cloud.com/api/v2/sites/221/nao_trackables?filter[tracking_id_or_name_in]=MyTagName,AA:BB:CC:DD:EE:FF'

 

The REST API can be used to create, update and delete tags. For more information, please refer to the REST API documentation.

Regions/Zones

In the same way, to get information of all the zones of the site, use the following API:

1GET /api/v2/sites/{siteID}/regions

Ex:
Request:

1curl -X GET --header 'Accept: application/json' --header 'Authorization: qTqsdqcPsfzNwJgF4uddQQ6vZw' 'https://www.nao-cloud.com/api/v2/sites/4028/regions'

Response:

1{
2  "regions":[
3    {
4      "id":35183,
5      "name":"My test zone",
6      "type":"PolygonRegion",
7      "polygon":"[[4.001915320729633,49.21828208973843],[4.002036503461478,49.21842478973541],[4.002285696121327,49.21832668353172],[4.0021781677818025,49.218194016878414],[4.001915320729633,49.21828208973843]]",
8      "alt":0.0,
9      "color":"#ee9900",
10      "category":"default"
11    }
12  ]
13}

Alerts

To get information of all the alerts of the site, use the following API:

1GET /api/v2/sites/{siteID}/alerts
Ex:
Request:
1curl -X GET --header 'Accept: application/json' --header 'Authorization: qTqsdqcPsfzNwJgF4uddQQ6vZw' 'https://www.nao-cloud.com/api/v2/sites/4028/alerts'

Response:

1{
2  "alerts":[
3    {
4      "id":31994,
5      "content":"",
6      "name":"My alert name",
7      "is_on":true,
8      "start_time":null,
9      "end_time":null,
10      "nao_application_id":4972,
11      "alert_rules":[
12        {
13          "id":31969,
14          "type":"EnterGeofenceRule",
15          "params":null,
16          "region_id":35183
17         }
18       ]
19     }
20   ]
21}
    • Related Articles

    • Alerts API

      Alerts are also available on the following dedicated topic so you don’t have to process all locations messages if you are only interested in alerts. 1 {environment}/{API_key}/alerts It also contains a Message Pack payload, it has the following ...
    • Getting maps metadata

      Each NAO Cloud site has 1 or more buildings. Each building has 1 or more floors. The metadata of each site, building and floor can be retrieved via the REST API. Buildings To get information of all the buildings of the site, use the following API: ...
    • Working offline – embed data files

      Some files are needed to use the NAO SDK Services in your app: app.json: for general service configuration and geofencing alerts definition. Only one file is required per API Key, no matter the number of NAO Cloud sites covered by this API Key. ...
    • Tags commissioning

      1. Adding a tag A tag can be created by sending a POST request to /api/v2/sites/{SITE_ID}/nao_trackables. The SITE_ID will be provided by Pole Star after the deployment of the site. NAO Cloud REST API – Add a tag If SITE_ID is 12061 and the ...
    • 4. Fetching Data

      Data, including resources and relationships, can be fetched by sending a GET request to an endpoint. The server responds to a successful request to fetch an individual resource or resource collection with a 200 OK response. A 404 Not found will be ...