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.
| 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 |
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
}
]
}
Returns details of the sensor requested
| Param name | Description |
|---|---|
|
pretty optional |
Return a pretty formatted response if true, Default is false Value: Must be a Boolean |
Request - get details of the specified sensor (sensor_key specified as a part of the url)
curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" https://api.datonis.io/api/v2/sensors/t42b258f9daef7ee64146651ef1dffc1b441df4t
Response (returns details of the sensor requested)
{
"sensor": {
"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
}
}
Creates a sensor with given parameters
| Param name | Description |
|---|---|
|
sensor required |
Object containing information about the sensor to be created Value: Must be a Hash |
|
pretty optional |
Return a pretty formatted response if true, Default is false Value: Must be a Boolean |
Request
curl -X POST -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"sensor":{"name":"WM-124","description":"WM-124","type":"Water Meter","tags":"1-Inch,Pune","coordinates":[18.123,73.123],"traits":{"status":"green"}}}' https://api.datonis.io/api/v2/sensors
Response (returns details of the sensor created)
{
"sensor": {
"bi_directional": false,
"coordinates": [
18.123,
73.123
],
"description": "WM-124",
"sensor_key": "6e78c8ad89f4fabfdda4a4144a92ca958ff84td9",
"type": "Water Meter",
"meta_data": null,
"name": "WM-124",
"state": null,
"tags_array": [
"1-Inch",
"Pune"
],
"traits": {
"status": "green"
},
"unit_of_measure": null,
"alive": false,
"tags": "1-Inch,Pune",
"last_event": null,
"last_beat": null,
"created_at": 1396514265,
"updated_at": 1416569091
}
}
Updates a sensor with given parameters
| Param name | Description |
|---|---|
|
sensor required |
Object containing information about the sensor to be updated Value: Must be a Hash |
|
pretty optional |
Return a pretty formatted response if true, Default is false Value: Must be a Boolean |
Request - containing parameters to be modified
curl -X PUT -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"sensor":{"description":"A water meter","tags":"1.5-Inch,Pune","traits":{"status":"green","customer_code":"12345"}}}' https://api.datonis.io/api/v2/sensors/t19afa692e4ttbce69e83b4e7585a94eaaf3f3e8
Response (returns details of the sensor updated)
{
"sensor": {
"bi_directional": false,
"coordinates": [
18.123,
73.123
],
"description": "A water meter",
"sensor_key": "t19afa692e4ttbce69e83b4e7585a94eaaf3f3e8",
"type": "Water Meter",
"meta_data": null,
"name": "WM-124",
"state": null,
"tags_array": [
"1.5-Inch",
"Pune"
],
"traits": {
"status": "green",
"customer_code": "12345"
},
"unit_of_measure": null,
"alive": false,
"tags": "1.5-Inch,Pune",
"last_event": null,
"last_beat": null
}
}
Deletes the specified sensor from the system. All associated data is also lost.
| Param name | Description |
|---|---|
|
pretty optional |
Return a pretty formatted response if true, Default is false Value: Must be a Boolean |
Request
curl -X DELETE -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" https://api.datonis.io/api/v2/sensors/t19afa692e4ttbce69e83b4e7585a94eaaf3f3e8
Response
{
}
Adds specified tags to an existing list of tags for a sensor
| Param name | Description |
|---|---|
|
tags optional |
Comma separated list of tags to be added to the sensor Value: Must be a String |
|
pretty optional |
Return a pretty formatted response if true, Default is false Value: Must be a Boolean |
Request - containing the list of tags to be added
curl -X PUT -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"tags":"Baner,3-wire"}' https://api.datonis.io/api/v2/sensors/16dc891e4b255735d7tafete13e6fdc412628t84/tag
Response (returns details of the sensor with updated tags)
{
"sensor": {
"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",
"Baner",
"3-wire"
],
"traits": {
...
Removes specified tags from the list of tags associated with a sensor
| Param name | Description |
|---|---|
|
tags optional |
Comma separated list of tags to be removed from the sensor Value: Must be a String |
|
pretty optional |
Return a pretty formatted response if true, Default is false Value: Must be a Boolean |
Request - containing the list of tags to be removed
curl -X PUT -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"tags":"Baner,3-wire"}' https://api.datonis.io/api/v2/sensors/16dc891e4b255735d7tafete13e6fdc412628t84/untag
Response (returns details of the sensor with updated tags)
{
"sensor": {
"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,
...
Adds specified user defined traits (properties) on a sensor
| Param name | Description |
|---|---|
|
traits optional |
map of key value pairs to be set Value: Must be a Hash |
|
pretty optional |
Return a pretty formatted response if true, Default is false Value: Must be a Boolean |
Request - containing traits (properties) to be added
curl -X PUT -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"traits":{"status":"green","customer_code":13433}}' https://api.datonis.io/api/v2/sensors/16dc891e4b255735d7tafete13e6fdc412628t84/set_traits
Response (returns details of the sensor with updated traits (properties))
{
"sensor": {
"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": {
"status": "green",
"customer_code": 13433
},
"unit_of_measure": null,
"alive": false,
"tags": "1-Phase,15-Amps,Pune",
"last_event": null,
"last_beat": 1428644189
}
}
Removes specified user defined traits (properties) on a sensor
| Param name | Description |
|---|---|
|
traits optional |
List of trait keys to be removed Value: Must be an array of any type |
|
pretty optional |
Return a pretty formatted response if true, Default is false Value: Must be a Boolean |
Request - containing traits (properties) to be removed
curl -X PUT -H "Content-Type:application/json" -H "X-Auth-Token:WtUFnj8pvSxVnH9e_xkq7A" -d '{"traits":["customer_code"]}' https://api.datonis.io/api/v2/sensors/16dc891e4b255735d7tafete13e6fdc412628t84/remove_traits
Response (returns details of the sensor with updated traits (properties))
{
"sensor": {
"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": {
"status": "green"
},
"unit_of_measure": null,
"alive": false,
"tags": "1-Phase,15-Amps,Pune",
"last_event": null,
"last_beat": 1428644189
}
}