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 single user identity
POST/v1.0/admin/thingsCreate 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

Example 1#

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
}
]
}

Example 2#

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"
}

Example 3#

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"
}

Example 4#

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
}

Example 5#

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'