Device service

Device service manages the device registry of ThingScale, aggregates information about all of the devices.

Each device accumulates the time series data to have been created by the channel (see Channel service).

When the access of time series data, use Stream service(see Stream service).

API Sandbox

List all devices

List device registries of thingscale.

Request Header:

Header: Description
X-APITOKEN API_TOKEN_HERE

Response Body:

Elements Type Descritption
device_id string DEVICE_ID
description string description of device
enabled boolean false : device disabled , true : device enabled
mapped_ch int device related channel_id
device_type string type of device
location string location of device
manufacturer string manufacturer of device
activate_at string activate time of device(ISO8601)

GET https://m.thingscale.io/v2/device/{device_id}

Parameters: device_id (String)

Sample payload:

[
    {
        "device_id": "1085266243",
        "description": "sht-25",
        "enabled": true,
        "mapped_ch": 0,
        "device_type": "Xbee Pro",
        "location": "Niigata,Japan",
        "manufacturer": "sensincs,llc",
        "activate_at": "2015-01-13 16:58:00"
    }
]
curl -X GET -H "X-APITOKEN: API_TOKEN_HERE" -k https://m.thingscale.io/v2/device/DEVICE_ID_HERE

Response code:

HTTP status: Desc./Response body
200 OK Transaction OK.
401 Unauthorized {"error": "AUTH_REQUIRED"}
404 Not found {"error": "NO_DEVICE"}

Create a new device

Add new device to registries of thingscale.

Request Header:

Header: Description
X-APITOKEN API_TOKEN_HERE

POST https://m.thingscale.io/v2/device/{device_id}

Parameters: device_id (String)

curl -X POST -H "X-APITOKEN: API_TOKEN_HERE" -k https://m.thingscale.io/v2/device/DEVICE_ID_HERE

Response code:

HTTP status: Desc./Response body
201 Created Device created.
401 Unauthorized {"error": "AUTH_REQUIRED"}
403 Forbidden { "error": "MAX_DEVICE_REACH" } // Per account device limit reached.
403 Forbidden { "error": "DEVICE_INUSE" } // Because the same channel as the specified ID exists, it could not be created.

Update a devices

Update a device registries of thingscale.

Request Header:

Header: Description
X-APITOKEN API_TOKEN_HERE

Response Body:

Elements Type Descritption
description string device description
enabled boolean device status
mapped_ch number device related channel-Id
device_type string type of device
location string location of device
manufacturer string manufacturer of device

PUT https://m.thingscale.io/v2/device/{device_id}

Parameters: device_id (String)

Sample payload:

{
"description" : "DEVICE_DESCRIPTION",
"enabled" : "DEVICE_STATUS", // true or false
"mapped_ch" : MAP_CHANNEL_NUMBER, // integer
"device_type" : "DEVICE_TYPE",
"location" : "DEVICE_LOCATION",
"manufacturer" : "DEVICE_MANUFACTURER"
}
curl -X PUT -H "X-APITOKEN: API_TOKEN_HERE" -k https://m.thingscale.io/v2/device/DEVICE_ID_HERE

Response code:

HTTP status: Desc./Response body
200 OK Transaction OK.
400 Bad Request { "error": "BAD_JSON_FORMAT" } // check json array
401 Unauthorized {"error": "AUTH_REQUIRED"}
403 Forbidden { "error": "NO_DEVICE" } // Specified device_id is not found.
404 Not found { "error": "NO_DEVICE" } // Specified device_id is not found.

Delete a devices

Delete a device registries of thingscale.

Request Header:

Header: Description
X-APITOKEN API_TOKEN_HERE

DELETE https://m.thingscale.io/v2/device/{device_id}

Parameters: device_id (String)

`curl curl -X DELETE -H "X-APITOKEN: API_TOKEN_HERE" -k https://m.thingscale.io/v2/device/DEVICE_ID_HERE

Response code:

HTTP status: Desc./Response body
200 OK Transaction OK.
401 Unauthorized {"error": "AUTH_REQUIRED"}
403 Forbidden { "error": "DEVICE_ENABLE" } // Specified device status is enable.
404 Not found { "error": "NO_DEVICE" } // Specified device_id is not found.

results matching ""

    No results matching ""