Query Devices

Query for devices in a number of ways using available filters.

Routes#

MethodURINameSummary
GET/v1.0/admin/thingsGet list of all devices
GET/v1.0/admin/things/countGet count of all devices
GET/v1.0/admin/things/{thing_id}Get one device
POST/v1.0/admin/thingsCreate a device
POST/v1.0/admin/things/{thing_id}/cmdSend a command to a device
PUT/v1.0/admin/things/{thing_id}Update a device
DELETE/v1.0/admin/things/{thing_id}Delete a device

Query Parameters#

NameSourceTypeValues
application_idquerystring
limitquerynumber
pagequerynumber
location_idquerynumber
statusquerynumber
user_idquerystring
thing_typequerystringdevices or gateways
external_id'query'string

Find all Devices#

Get all devices for specific User**#

Example call to query devices for a user (e.g. one of our two users pulled in the previous example). In this case we'll query against robcan...@yopmail.com, user 99e86f3f-87f4-4d7e-9e87-529e16f27438:

alt text Note how we filter by a specific user_id.

curl --request GET --url https://api.iotinabox.com/v1.0/admin/things?page=0&limit=50&user_id=99e86f3f-87f4-4d7e-9e87-529e16f27438 \
--header 'authorization: Bearer MyAuthTokenHere' \
--header 'content-type: application/json'

Example Response (robcan...@yopmail.com's devices):

{
"count": 2,
"limit": 50,
"page": 0,
"rows": [
{
"sensor_type": null,
"created_at": "2019-05-07T23:04:25.000Z",
"sensor_use": null,
"thing_type": 0,
"thing_name": "Gateway",
"properties": "{\"codec\":\"lorawan.gateway.iotb\"}",
"company_id": 937,
"hardware_id": "eui-00001c497bb44...",
"device_type_id": "36c52526-e689-11e7-80c1-9a214cf093ce",
"application_id": "iot-solutions-canada",
"sensor_use_id": null,
"location_id": 890,
"id": 70006075,
"enabled": 1,
"status": 0,
"user_id": "99e86f3f-87f4-4d7e-9e87-529e16f27438",
"parent_id": null,
"updated_at": "2019-05-07T23:04:25.000Z",
"cayenne_id": "75722a70-711c-11e9-9fd4-e73c33d2d42c"
},
{
"company_id": 937,
"hardware_id": "00137a1000000...",
"device_type_id": "121f6268-e52b-11e7-80c1-9a214cf093ae",
"sensor_type": "Open/Close",
"created_at": "2019-05-07T23:04:45.000Z",
"thing_type": 1,
"sensor_use": "Door",
"thing_name": "OCRPP",
"properties": "{}",
"application_id": "iot-solutions-canada",
"id": 70006076,
"enabled": 1,
"sensor_use_id": null,
"location_id": 890,
"cayenne_id": "815f4c00-711c-11e9-9fd4-e73c33d2d42c",
"updated_at": "2019-05-09T17:00:11.000Z",
"user_id": "99e86f3f-87f4-4d7e-9e87-529e16f27438",
"status": 1,
"parent_id": null
}
]
}

Create a Device#

Create a Device

curl --request POST --url https://api.iotinabox.com/v1.0/admin/things \
--header 'authorization: Bearer MyAuthTokenHere' \
--header 'content-type: application/json'
--data \
'{
"user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b",
"application_id": "iotinabox",
"company_id": 464,
"location_id": 445,
"device": {
"hardware_id": "a130000000000ff",
"name": "thing_name_5",
"sensor_use": "use5",
"sensor_type": "Ethernet Gateway",
"device_category": "module",
"external_id": "my_external_id_4"
}
}'

Example Response:

{
"id": 1405,
"location_id": 445,
"company_id": 464,
"parent_id": null,
"cayenne_id": "d3fd3d80-6446-11ec-a762-a52e6bb2c8ed",
"hardware_id": "a130000000000ff",
"sensor_use_id": null,
"sensor_use": "use6",
"sensor_type": "Ethernet Gateway",
"thing_name": "thing_name_5",
"thing_type": 1,
"marker_alert": "animate",
"properties": "{\"codec\":\"lorawan.gateway.iotb\",\"deveui\":\"a130000000000ff\",\"network\":\"iotinabox\",\"activation\":\"activated\",\"device_registry_id\":\"4b918ff0-641e-11ec-a762-a52e6bb2c8ed\",\"codec.vol_unit\":\"m3\",\"codec.prox_unit\":\"m\"}",
"device_type_id": "1e563f10-cc0d-11e8-9c69-e9c14d851ba4",
"enabled": 1,
"user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b",
"application_id": "iotinabox",
"status": 0,
"created_at": "2021-12-23T23:19:53.000Z",
"updated_at": "2022-01-03T17:27:41.000Z",
"external_id": "my_external_id_4",
"createdAt": "2021-12-23T23:19:53.000Z",
"updatedAt": "2022-01-03T17:27:41.000Z"
}

Update Device#

Update a Device

curl --request PUT --url https://api.iotinabox.com/v1.0/admin/things/d3fd3d80-6446-11ec-a762-a52e6bb2c8ed \
--header 'authorization: Bearer MyAuthTokenHere' \
--header 'content-type: application/json'
--data \
'{
"user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b",
"application_id": "iotinabox",
"sensor_use": "use6",
"name": "thing_name_6",
"external_id": "my_external_id_5",
"company_id": 464,
"location_id": 445
}'

Example Response:

{
"id": 1405,
"location_id": 445,
"company_id": 464,
"parent_id": null,
"cayenne_id": "d3fd3d80-6446-11ec-a762-a52e6bb2c8ed",
"hardware_id": "a130000000000ff",
"sensor_use_id": null,
"sensor_use": "use6",
"sensor_type": "Ethernet Gateway",
"thing_name": "thing_name_6",
"thing_type": 1,
"marker_alert": "animate",
"properties": "{\"codec\":\"lorawan.gateway.iotb\",\"deveui\":\"a130000000000ff\",\"network\":\"iotinabox\",\"activation\":\"activated\",\"device_registry_id\":\"4b918ff0-641e-11ec-a762-a52e6bb2c8ed\",\"codec.vol_unit\":\"m3\",\"codec.prox_unit\":\"m\"}",
"device_type_id": "1e563f10-cc0d-11e8-9c69-e9c14d851ba4",
"enabled": 1,
"user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b",
"application_id": "iotinabox",
"status": 0,
"created_at": "2021-12-23T23:19:53.000Z",
"updated_at": "2022-01-03T17:27:41.000Z",
"external_id": "my_external_id_5",
"createdAt": "2021-12-23T23:19:53.000Z",
"updatedAt": "2022-01-03T17:27:41.000Z"
}

Remove Device#

Delete a Device

curl --request DELETE --url https://api.iotinabox.com/v1.0/admin/things/d3fd3d80-6446-11ec-a762-a52e6bb2c8ed \
--header 'authorization: Bearer MyAuthTokenHere' \
--header 'content-type: application/json'
--data \
'{
"user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b"
}'

Example Response:

{
"success": true
}

Get Device by External Id#

Get a Device by External Id

curl -- request GET \
-- url https://api.iotinabox.com/v1.0/admin/things?external_id=1234 \
-- header 'Authorization: Bearer YourAuthToken' \
-- header 'Content-Type: application/json'

Send Device Command#

Send Device Commands

curl --request POST \
--url http://localhost:3000/v1.0/admin/things/6df450e0-91f0-11ed-9d8f-f9c593f1db51/cmd \
--header 'Authorization: Bearer >>your token here<<' \
--header 'Content-Type: application/json' \
--data '{
"channel": "57",
"value": 1
}'

In the above example the channel must be one of the device capabilities found under device templates. The value depends on the type of capability. Here we have a stop alert downlink and the value must be equal to 1.