Skip to main content

REST API

Overview

REST API

Return Value Interface Specification

NameLocationTypeDescription
request_idbodystringUnique request identifier ID
statusbodystringRequest status: Success/Failed
error_codebodystringError code, present when status is Failed
error_messagebodystringError message, present when status is Failed
detail_messagebodystringDetailed error message, possibly present when status is Failed
databodyobjectReturned result data, generally present when status is Success

Authentication

POST Token Refresh

POST /oauth2/token

Request Parameters

NameLocationTypeRequiredDescription
bodybodyobjectNonone
» refresh_tokenbodystringNonone
» grant_typebodystringNonone
» client_idbodystringNonone
» client_secretbodystringNonone
» usernamebodystringNonone
» passwordbodystringNonone

Body Request Parameters

refresh_token: string
grant_type: password
client_id: iab
client_secret: milesight*iab
username: string
password: string

Response

Status CodeDescriptionData Model
200OKSuccess

Response Example

200 Response

{
"access_token": "string",
"expires_in": 0,
"refresh_token": "string"
}

POST User Registration

POST /user/register

Request Parameters

NameLocationTypeRequiredDescription
bodybodyobjectNonone
» emailbodystringYesnone
» nicknamebodystringYesnone
» passwordbodystringYesnone

Body Request Parameters

{
"email": "string",
"nickname": "string",
"password": "string"
}

Response

Status CodeDescriptionData Model
200OKSuccess

Response Example

200 Response

{}

GET User Status Information

GET /user/status

Response

Status CodeDescriptionData Model
200OKSuccess

Response Example

200 Response

{
"data": {
"init": true
}
}

Integration

POST Get Integration List

POST /integration/search

Request Parameters

NameLocationTypeRequiredDescription
device_addablebodybooleanNoWhether to return integrations that can add devices
device_deletablebodybooleanNoWhether to return integrations that can delete devices

Body Request Parameters

{
"device_addable": true,
"device_deletable": true
}

Response

Field NameField TypeDescription
$objectIntegration information list item
$.idstringIntegration ID
$.iconstringIntegration icon URL
$.namestringIntegration name
$.descriptionstringIntegration description
$.add_device_service_keystringAdd device service entity key
$.device_countnumberNumber of devices
$.entity_countnumberNumber of entities (including device and integration entities)

Response Example

Success

{
"data": [
{
"id": "",
"icon": "",
"name": "",
"description": "",
"add_device_service_key": "",
"deviceCount": 0,
"entityCount": 0
}
]
}

GET Get Integration Details

GET /integration/{integration_id}

Request Parameters

NameLocationTypeRequiredDescription
integration_idpathstringYesIntegration ID

Response

Field NameField TypeDescription
idstringIntegration ID
iconstringIntegration icon URL
namestringIntegration name
descriptionstringIntegration description
add_device_service_keystringAdd device service entity key
entity_countnumberNumber of entities (including device and integration entities)
delete_device_service_keystringDelete device service entity key
integration_entitiesarrayList of integration entities
integration_entities.$objectIntegration entity list item
integration_entities.$.idstringEntity ID
integration_entities.$.keystringEntity key
integration_entities.$.namestringEntity name
integration_entities.$.typestringEntity type (PROPERTY / SERVICE / EVENT)
integration_entities.$.value_attributeobjectEntity attribute
integration_entities.$.value_typestringData type (STRING / LONG / DOUBLE / BOOLEAN / BINARY / OBJECT)
integration_entities.$.access_modstringRead/Write (R / W / RW) - only for property type entities
integration_entities.$.parentstringParent entity key
integration_entities.$.valuestringCurrent value of the entity

Response Example

Success

{
"data": {
"id": "",
"icon": "",
"name": "",
"description": "",
"add_device_service_key": "",
"deviceCount": 0,
"entityCount": 0,
"delete_device_service_key": "",
"integration_entities": [
{
"id": "",
"key": "",
"name": "",
"type": "",
"value_attribute": {
"": {}
},
"value_type": "",
"access_mod": "",
"parent": "",
"value": {}
}
]
}
}

Devices

POST Create Device

POST /device

Request Parameters

NameLocationTypeRequiredDescription
namebodystringYesDevice name
integrationbodystringYesIntegration ID
param_entitiesbodyobjectYesParameters required for adding the device service

Body Request Parameters

{
"name": "string",
"integration": "string",
"param_entities": {
"key": "value"
}
}

Response

Response Example

Success

{}

POST Search Devices

POST /device/search

Request Parameters

NameLocationTypeRequiredDescription
namebodystringNoDevice name to search
page_numberbodynumberNoPage number
page_sizebodynumberNoPage size

Body Request Parameters

{
"name": "",
"page_number": 1,
"page_size": 10
}

Response

Response Example

Success

{
"data": {
"page_size": 0,
"page_number": 0,
"total": 0,
"content": [
{
"id": "",
"key": "",
"name": "",
"integration": "",
"additional_data": {},
"created_at": 0,
"updated_at": 0,
"integration_name": "",
"deletable": true
}
]
}
}

PUT Update Device Information

PUT /device/{device_id}

Request Parameters

NameLocationTypeRequiredDescription
device_idpathstringYesDevice ID
namebodystringNoDevice name

Body Request Parameters

{
"name": "string"
}

Response

Response Example

Success

{}

GET Get Device Details

GET /device/{device_id}

Request Parameters

NameLocationTypeRequiredDescription
device_idpathstringYesDevice ID

Response

Field NameField TypeDescription
idstringDevice ID
keystringDevice key
namestringDevice name
integrationstringIntegration ID
integration_namestringIntegration name
additional_dataobjectAdditional data
created_atnumberCreation timestamp
updated_atnumberUpdate timestamp
deletablebooleanDeletable flag
identifierstringIdentifier
entitiesarrayList of device entities
entities.$objectDevice entity list item
entities.$.idstringEntity ID
entities.$.keystringEntity key
entities.$.namestringEntity name
entities.$.typestringEntity type
entities.$.value_attributeobjectEntity attribute
entities.$.value_typestringEntity value type

Response Example

Success

{
"data": {
"id": "",
"key": "",
"name": "",
"integration": "",
"additional_data": {
"": {}
},
"created_at": 0,
"updated_at": 0,
"integration_name": "",
"deletable": false,
"identifier": "",
"entities": [
{
"id": "",
"key": "",
"name": "",
"type": "",
"value_attribute": {
"": {}
},
"value_type": ""
}
]
}
}

POST Batch Delete Devices

POST /device/batch-delete

Request Parameters

NameLocationTypeRequiredDescription
device_id_listbodyarrayYesList of device IDs to delete
device_id_list.$bodystringYesDevice ID

Body Request Parameters

{
"device_id_list": [
"string"
]
}

Response

Response Example

Success

{}

Entities

POST Query Entities

POST /entity/search

Request Parameters

NameLocationTypeRequiredDescription
bodybodyobjectNonone

Body Request Parameters

{
"keyword": "string",
"entityType": ["PROPERTY", "SERVICE", "EVENT"],
"excludeChildren": "Boolean",
"entityValueType": ["STRING", "LONG", "DOUBLE", "BOOLEAN", "BINARY", "OBJECT"],
"entityAccessMod": ["R", "W", "RW"]
}

Response

Status CodeDescriptionData Model
200OKSuccess
» entityIdstringnone
» entityNamestringnone
» entityTypestringnone
» entityValueTypestringnone
» entityValueAttributeobjectnone
» entityAccessModstringnone
» entityKeystringnone
» deviceNamestringnone
» integrationNamestringnone

Response Example

Success

{
"data": {
"deviceName": "String",
"integrationName": "String",
"entityId": "String",
"entityAccessMod": "String",
"entityKey": "String",
"entityName": "String",
"entityType": "String",
"entityValueAttribute": {},
"entityValueType": "String"
}
}

GET Get Child Entities

GET /entity/{entityId}/children

Request Parameters

NameLocationTypeRequiredDescription
entityIdpathstringYesnone

Response

Status CodeDescriptionData Model
200OKSuccess
dataarraynone
» entityIdstringnone
» entityNamestringnone
» entityTypestringnone
» entityValueTypestringnone
» entityValueAttributeobjectnone
» entityAccessModstringnone
» integrationNamestringnone
» deviceNamestringnone
» entityKeystringnone

Response Example

Success

{
"data": [
{
"deviceName": "",
"integrationName": "",
"entityId": "",
"entityAccessMod": "",
"entityKey": "",
"entityType": "",
"entityName": "",
"entityValueAttribute": {
"": {}
},
"entityValueType": ""
}
]
}

POST Query Historical Data

POST /entity/history/search

Request Parameters

NameLocationTypeRequiredDescription
bodybodyobjectNonone

Body Request Parameters

{
"entityId": 0,
"startTimestamp": 0,
"endTimestamp": 0
}

Response

Status CodeDescriptionData Model
200OKSuccess
» timestampintegernone
» valueobjectnone
» valueTypestringnone

Response Example

Success

{
"timestamp": 0,
"value": "Object",
"valueType": "String[STRING, LONG, DOUBLE, BOOLEAN, BINARY, OBJECT]"
}

POST Query Historical Data Aggregation

POST /entity/history/aggregate

Request Parameters

NameLocationTypeRequiredDescription
bodybodyobjectNonone

Body Request Parameters

{
"entityId": 0,
"aggregateType": "LAST",
"startTimestamp": 0,
"endTimestamp": 0
}

Response

Status CodeDescriptionData Model
200OKSuccess
» valueobjectnone
» valueTypestringnone
» countResultarraynone
»» valueobjectnone
»» valueTypestringnone
»» countintegernone

Response Example

Success

{
"data":{
"value": {},
"valueType": "",
"countResult": [
{
"value": {},
"valueType": "",
"count": 0
}
]
}
}

GET Retrieve the Latest Value of an Entity

GET /entity/{entityId}/status

Request Parameters

NameLocationTypeRequiredDescription
entityIdpathstringYesnone

Response

Status CodeMeaningDescriptionData Model
200OKSuccessObject
» valueobjectnonenone
» updatedAtstringnonenone
» valueTypestringnonenone

Example Response

Success

{
"data": {
"value": {},
"updatedAt": "",
"valueType": ""
}
}

GET Retrieve Entity Metadata

GET /entity/{entityId}/meta

Request Parameters

NameLocationTypeRequiredDescription
entityIdpathstringYesnone

Response

Status CodeMeaningDescriptionData Model
200OKSuccessObject
» keystringnonenone
» namestringnonenone
» typestringnonenone
» accessModstringnonenone
» valueAttributeobjectnonenone
» valueTypestringnonenone

Example Response

Success

{
"data": {
"key": "",
"name": "",
"type": "",
"accessMod": "",
"valueAttribute": {
"": {}
},
"valueType": ""
}
}

Dashboard

POST Create Dashboard

POST /dashboard

Request Parameters

NameLocationTypeRequiredDescription
bodybodyObjectNonone
» namebodystringYesnone

Body Request Example

{
"name": "string"
}

Response

Status CodeMeaningDescriptionData Model
200OKSuccessObject

Example Response

Success

{
"data": {
"dashboardId": ""
}
}

PUT Update Dashboard

PUT /dashboard/{dashboardId}

Request Parameters

NameLocationTypeRequiredDescription
dashboardIdpathstringYesnone
bodybodyObjectNonone
» namebodystringYesnone
» widgetsbodyArrayYesnone
»» widgetIdbodystringYesnone
»» databodyObjectYesnone

Body Request Example

{
"name": "string",
"widgets": [
{
"widgetId": "string",
"data": {
}
}
]
}

Response

Status CodeMeaningDescriptionData Model
200OKSuccessObject

Example Response

Success

{
"data": {

}
}

DELETE Delete Dashboard

DELETE /dashboard/{dashboardId}

Request Parameters

NameLocationTypeRequiredDescription
dashboardIdpathstringYesnone

Response

Status CodeMeaningDescriptionData Model
200OKSuccessObject

Example Response

Success

{
"data": {

}
}

GET Retrieve All Dashboards

GET /dashboard/dashboards

Response

Status CodeMeaningDescriptionData Model
200OKSuccessObject
dataArraynoneArray
» dashboardIdstringnoneString
» namestringnoneString
» widgetsArraynoneArray
»» widgetIdstringnoneString
»» dataObjectnoneObject
» createdAtstringnoneString

Example Response

Success

{
"data": [
{
"dashboardId": "",
"name": "",
"widgets": [
{
"widgetId": "",
"data": {
"": {}
}
}
],
"createdAt": ""
}
]
}

WebSocket

WebSocket connection URL: ws://{host}:{port}/websocket

Request Parameters

NameLocationTypeRequiredDescription
AuthorizationquerystringYesnone