Returns a list of all sensors belonging to an account as per the specified criteria. This API is paginated and returns 20 sensors by default. A sensor is uniquely identified by a 'sensor_key'. This key should be used in all the other API referencing a particular sensor.

Params

Param name Description
page
optional

Page number of results to be fetched, Default 1


Value: Must be Integer.
per
optional

Number of sensors records to be returned in one page, Default 20


Value: Must be Integer.
order_by
optional

Field on which resultant sensors should be sorted


Value: Must be a String
order
optional

Order, asc or desc, in which results should be sorted


Value: Must be a String
sensors
optional

List of sensors that should be queried for

timestamp_format
optional

Format, “str” or “int”, in which timestamps should be returned, Default “int”


Value: Must be a String
search
optional

Keywords based on which sensors should be searched. Currently you can search sensors on - sensor_key, name or tag


Value: Must be a String
scope
optional

Matching condition if multiple keywords are specified for search. Valid values are “all” or “any”. Default is “all”


Value: Must be a String
bi_directional
optional

Whether to return sensors that have bi-directional support, Default all will be returned


Value: Must be a Boolean
expr
optional

Expression based on traits for searching sensors based on trait value


Value: Must be a String
pretty
optional

Return a pretty formatted response if true, Default is false


Value: Must be a Boolean
group_key
optional

Returns sensors belonging to the specified group


Value: Must be a String
field_list
optional

List of fields required in the result.


Value: Must be an array of any type
fields
optional

[Deprecated]Comma separated list of fields required in the result.


Value: Must be a String

Examples

Request - listing all sensors without any criteria
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" https://api.datonis.io/api/v2/sensors

Response (returns first 20 records)
{
  "total_count": 4,
  "page": 1,
  "sensors": [
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "16dc891e4b255735d7tafete13e6fdc412628t84",
      "type": "Energy Meter",
      "meta_data": {
        "properties": {
          "voltage": {
            "type": "number"
          },
          "power": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "EM-100",
      "state": "registered",
      "tags_array": [
        "1-Phase",
        "15-Amps",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Phase,15-Amps,Pune",
      "last_event": null,
      "last_beat": 1428644189,
      "created_at": 1396514265,
      "updated_at": 1416569091
    },
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "27ce8667143fa217b3eb9ecbedcbacdc28addt97",
      "type": "Energy Meter",
      "meta_data": {
        "properties": {
          "voltage": {
            "type": "number"
          },
          "power": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "EM-101",
      "state": "registered",
      "tags_array": [
        "1-Phase",
        "15-Amps",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Phase,15-Amps,Pune",
...
Request - listing sensors by specifying number of sensors to be returned at a time (page size) and specific set to be returned (page)
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"per":"2", "page":"2"}' https://api.datonis.io/api/v2/sensors

Response (returns page 2 with 2 sensors per page)
{
  "total_count": 4,
  "page": "2",
  "sensors": [
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "t42b258f9daef7ee64146651ef1dffc1b441df4t",
      "type": "Compressor",
      "meta_data": {
        "properties": {
          "pressure": {
            "type": "number"
          },
          "temperature": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "CMP-222",
      "state": "registered",
      "tags_array": [
        "Pune",
        "Reciprocating"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "Pune,Reciprocating",
      "last_event": null,
      "last_beat": 1428650668,
      "created_at": 1396514265,
      "updated_at": 1416569091
    },
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "554ed8f4c31f5be2336a173cfa183tbc9ab1b9t2",
      "type": "Compressor",
      "meta_data": {
        "properties": {
          "pressure": {
            "type": "number"
          },
          "temperature": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "CMP-131",
      "state": "registered",
      "tags_array": [
        "Pune",
        "Reciprocating"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "Pune,Reciprocating",
     ...
Request - listing sensors ordered by a field with string formatted timestamps
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"timestamp_format":"str","order_by":"name","order":"desc"}' https://api.datonis.io/api/v2/sensors

Response (returns sensors in the reverse order of name and timestamps in string format)
{
  "total_count": 5,
  "page": 1,
  "sensors": [
    {
      "bi_directional": true,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "38t376bbtfa72c459d7e1fe3febcc1b3edde487e",
      "type": "Water Meter",
      "meta_data": null,
      "name": "WM-211",
      "state": null,
      "tags_array": [
        "1-Inch",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Inch,Pune",
      "last_event": null,
      "last_beat": null,
      "created_at": "2014/04/03 08:37:45",
      "updated_at": "2014/11/21 11:24:51"
    },
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "27ce8667143fa217b3eb9ecbedcbacdc28addt97",
      "type": "Energy Meter",
      "meta_data": {
        "properties": {
          "voltage": {
            "type": "number"
          },
          "power": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "EM-101",
      "state": "registered",
      "tags_array": [
        "1-Phase",
        "15-Amps",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Phase,15-Amps,Pune",
      "last_event": null,
      "last_beat": "2015/04/10 05:37:19",
      "created_at": "2014/04/03 08:37:45",
      "updated_at": "2014/11/21 11:24:51"
    },
    {
      "bi_directional": false,
      "coordinates": [
       ...
Request - listing sensors based on some search criteria with all keywords matching
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"search":"Energy Meter"}' https://api.datonis.io/api/v2/sensors

Response (returns sensors containing both keywords 'Energy' as well as 'Meter')
{
  "total_count": 2,
  "page": 1,
  "sensors": [
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "16dc891e4b255735d7tafete13e6fdc412628t84",
      "type": "Energy Meter",
      "meta_data": {
        "properties": {
          "voltage": {
            "type": "number"
          },
          "power": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "EM-100",
      "state": "registered",
      "tags_array": [
        "1-Phase",
        "15-Amps",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Phase,15-Amps,Pune",
      "last_event": null,
      "last_beat": 1428644189,
      "created_at": 1396514265,
      "updated_at": 1416569091
    },
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "27ce8667143fa217b3eb9ecbedcbacdc28addt97",
      "type": "Energy Meter",
      "meta_data": {
        "properties": {
          "voltage": {
            "type": "number"
          },
          "power": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "EM-101",
      "state": "registered",
      "tags_array": [
        "1-Phase",
        "15-Amps",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Phase,15-Amps,Pune",
...
Request - listing sensors based on some search criteria with any of the keywords matching
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"search":"Energy Meter","scope":"any"}' https://api.datonis.io/api/v2/sensors

Response (returns sensors containing either of the keywords 'Energy' or 'Meter')
{
  "total_count": 3,
  "page": 1,
  "sensors": [
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "16dc891e4b255735d7tafete13e6fdc412628t84",
      "type": "Energy Meter",
      "meta_data": {
        "properties": {
          "voltage": {
            "type": "number"
          },
          "power": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "EM-100",
      "state": "registered",
      "tags_array": [
        "1-Phase",
        "15-Amps",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Phase,15-Amps,Pune",
      "last_event": null,
      "last_beat": 1428644189,
      "created_at": 1396514265,
      "updated_at": 1416569091
    },
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "27ce8667143fa217b3eb9ecbedcbacdc28addt97",
      "type": "Energy Meter",
      "meta_data": {
        "properties": {
          "voltage": {
            "type": "number"
          },
          "power": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "EM-101",
      "state": "registered",
      "tags_array": [
        "1-Phase",
        "15-Amps",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Phase,15-Amps,Pune",
      "last_event": null,
      "last_beat": 1428644239,
      "created_at": 1396514265,
      "updated_at": 1416569091
    },
    {
      "bi_directional": true,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "38t376bbtfa72c459d7e1fe3febcc1b3edde487e",
      "type": "Water Meter",
      "meta_data": null,
      "name": "WM-211",
      "state": null,
      "tags_array": [
        "1-Inch",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Inch,Pune",
      "last_event": null,
      "last_beat": null
    }
  ]
}
Request - listing sensors based on keys specified
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"sensors":["t42b258f9daef7ee64146651ef1dffc1b441df4t","27ce8667143fa217b3eb9ecbedcbacdc28addt97"]}' https://api.datonis.io/api/v2/sensors

Response (returns sensors matching the keys specified)
{
  "total_count": 2,
  "page": 1,
  "sensors": [
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "27ce8667143fa217b3eb9ecbedcbacdc28addt97",
      "type": "Energy Meter",
      "meta_data": {
        "properties": {
          "voltage": {
            "type": "number"
          },
          "power": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "EM-101",
      "state": "registered",
      "tags_array": [
        "1-Phase",
        "15-Amps",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Phase,15-Amps,Pune",
      "last_event": null,
      "last_beat": 1428644239,
      "created_at": 1396514265,
      "updated_at": 1416569091
    },
    {
      "bi_directional": false,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "t42b258f9daef7ee64146651ef1dffc1b441df4t",
      "type": "Compressor",
      "meta_data": {
        "properties": {
          "pressure": {
            "type": "number"
          },
          "temperature": {
            "type": "number"
          }
        },
        "additionalProperties": false
      },
      "name": "CMP-222",
      "state": "registered",
      "tags_array": [
        "Pune",
        "Reciprocating"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "Pune,Reciprocating",
     ...
Request - listing sensors that support bi directional communication
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"bi_directional":true}' https://api.datonis.io/api/v2/sensors

Response (returns sensors that support bi_directional communication)
{
  "total_count": 1,
  "page": 1,
  "sensors": [
    {
      "bi_directional": true,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "38t376bbtfa72c459d7e1fe3febcc1b3edde487e",
      "type": "Water Meter",
      "meta_data": null,
      "name": "WM-211",
      "state": null,
      "tags_array": [
        "1-Inch",
        "Pune"
      ],
      "traits": {
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Inch,Pune",
      "last_event": null,
      "last_beat": null,
      "created_at": 1396514265,
      "updated_at": 1416569091
    }
  ]
}
Request - listing sensors based on given expression for traits
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"expr":"this.traits.foo=='bar'"}' https://api.datonis.io/api/v2/sensors

Response (returns sensors after evaluating expression based on traits)
{
  "total_count": 1,
  "page": 1,
  "sensors": [
    {
      "bi_directional": true,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "38t376bbtfa72c459d7e1fe3febcc1b3edde487e",
      "type": "Water Meter",
      "meta_data": null,
      "name": "WM-211",
      "state": null,
      "tags_array": [
        "1-Inch",
        "Pune"
      ],
      "traits": {
        "foo": "bar"
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Inch,Pune",
      "last_event": null,
      "last_beat": null,
      "created_at": 1396514265,
      "updated_at": 1416569091
    }
  ]
}
Request - listing sensors that belong to a group
  curl -X GET  -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"group_key":"b7f28b97f8"}' https://api.datonis.io/api/v2/sensors

Response (returns sensors belonging to the specified group)
{
  "total_count": 1,
  "page": 1,
  "sensors": [
    {
      "bi_directional": true,
      "coordinates": [
        "18.5203",
        "73.8567"
      ],
      "description": "",
      "sensor_key": "38t376bbtfa72c459d7e1fe3febcc1b3edde487e",
      "type": "Water Meter",
      "meta_data": null,
      "name": "WM-211",
      "state": null,
      "tags_array": [
        "1-Inch",
        "Pune"
      ],
      "traits": {
        "foo": "bar"
      },
      "unit_of_measure": null,
      "alive": false,
      "tags": "1-Inch,Pune",
      "last_event": null,
      "last_beat": null,
      "created_at": 1396514265,
      "updated_at": 1416569091
    }
  ]
}