Getting started
- Toru Murasawa
In this chapter, we describe the basic matters required when to use the API.
Using API
ThingScale RESTful API is implemented as JSON over HTTP requests verbs GET/POST/PUT/DELETE.
Currently, APIs are provided below.
- /wiki/spaces/TD/pages/491587 : manage devices,channel assign,activate
- /wiki/spaces/TD/pages/491585 : channel settings,manage metadata
- /wiki/spaces/TD/pages/491564 : Retrieve(Write) Stream
- /wiki/spaces/TD/pages/491600 : manage threshold and notification
- /wiki/spaces/TD/pages/491619 : manage user profile
- /wiki/spaces/TD/pages/8454189 : Publish MQTT messages to device
- /wiki/spaces/TD/pages/76972089: Showing active pub/sub clients.
API Versioning
API version is specified in endpoint URI.(e.g. https://m.thingscale.io/v2
/<SERVICE_NAME>)
Current API version and release note are here Release Note
Security
All communication with ThingScale is performed over https(HTTP over TLS).
This ensures that all communication between ThingScale and device is over an encrypted communication.
HTTP/MQTT device connector can use plain-http and non-encrypted TCP communication for small memory footprint MCUs.(MCU:Micro Control Unit)
HTTP/HTTPS both protocols have pros and cons, choosing the right one depend on your environment and security trade-off.
We STRONGLY RECOMMENDED HTTPS/MQTTS for secure connection.
Protocol | Security | Resource requirement for MCUs |
---|---|---|
HTTP/MQTT | Poor(Non-encryption) | Low |
HTTPS/MQTTS | Excellent(Avoid men-in-middle attack) | High(Use more memory and CPU cycles..) |
Token
Tokens are per-user unique authorize key for API/Device connector.
In all cases you want to use the API token, it is strongly recommended that you use the HTTPS(TLS) connection.
- API Token
All RESTful API operation use API token.
- Device Token
For use only data sending from device to ThingScale with HTTP/MQTT connector.
NOTE
Device token is not per-device, per-user. Reason as in order to reduce the configuration task at the time of device distribution.
fig.2 Token Overview
Role of Token:
Token type: | REST API | HTTP/MQTT connector |
---|---|---|
API Token | Can use | X |
Device Token | X | Can use |
Data-format and timestamps
All API requests and responses use the JSON payloads only.
HTTP and MQTT device connector use the URL Encodeded payloads.
All timestamps are relative to UTC.Timestamps format is ISO8601:2004 standard.
NOTE
when stream retrieve,time range specified local timezone.(e.g. 'YYYY-MM-DD hh:mm')
Sample
{"_id":"54d3fc256807f4a616acbb33","value":11.1,"value2":47.9,"value3":null,"value4":null,"at":"2015-02-06T08:26:29+0900"}
{ "device_id": "1085266243", "description": "sensirion sht-25", "enable": "true", "mapped_ch": 0, "device_type": "Xbee Pro2", "location": "Niigata,Japan", "manufacturer": "Sensincs,llc", "activate_at": "2015-01-13T16:58:00+09:00" }
API rate limit
API usage is rate limited by per-second API request numbers.
The device connector rate limit by per-minutes request numbers.
NOTE
If the connection count has reached the upper limit,then API returns 429 Too Many Requests HTTP status code.
Current rate limit settings as follows:
- REST API
20 requests/sec. - Device Connector(HTTP ONLY)
1 connection/sec.
Channel
Channel is a logical channel that stores the data transmitted from the device.
It is not to specify the channel directly from the device, you will be distributed from the device_id(device's serial).
Channel is a timeseries database with schema less JSON objects, each stream can be specified labels and units.
Stream
Stream is datapoints that send device's sensor data.(e.g. temperature)
Stream has numeric(integer or float) or alphanumeric(like RFID UID) value.
Data type is determine by platform side.
NOTE
alphanumeric value MUST BE ENCODE UTF-8.
Data type sample:
12.5 : numeric
"Hello!" : string
{"temp" : 25, "humidity" : 50} : JSON objects
Device
Device means the WSN gateway or end device.
The device basically manually activated, but it is also possible to activate automatically.
Requires there to map the device to the channel in any case.
- Manual create
Case:Create from Management Console. - Automatically create
Case:When you connect the device for the first time in ThingScale.
On this page:
Related pages
Filter by label
There are no items with the selected labels at this time.
© 2014-2022 SENSINICS,LLC