GET /cn/:cn/data_stream - Use non persistent web socket to all your devices

Opens WebSocket to Kaltiot Smart Cloud. Kaltiot Smart Gateway SDK will push data from IoT Device to this WebSocket when there are new data available at IoT Device. Data comes as array of JSON objects. Websocket session is not persistent, meaning when there is no websocket connection, data from device is not buffered. If you want data to be buffered, create websocket session first using Http POST.

Request Parameters

ParameterDataTypeDescription
cnstringCommon Name, Identifier which is common for all your device

Example client request of establishing websocket connection

GET /cn/example_cn/data_stream?ApiKey=example_apikey HTTP/1.1
Upgrade: WebSocket
Connection: Upgrade
Origin: http://127.0.0.1:8080
Sec-WebSocket-Key: KzJwcJDCSruzORfG59fR9g==
Sec-WebSocket-Version: 13
Host: 127.0.0.1:8080
Accept: */*
User-Agent: AHC/1.0
Content-Length: 0

Example server response for establishing websocket connection

HTTP/1.1 101 Switching Protocols

Upgrade: websocket

Connection: Upgrade

Sec-WebSocket-Accept: yTLy8kTvOiexc2/CyyJqLGJbd7I=

Response Status Codes

Server will return 101 http code if WebSocket connection was accepted by server

For error cases see: Error Status Codes

Response Data Parameters

ParameterDatatypeDescription
ridstringUnique identifier to your device
timestampnumbertime in milliseconds from Jan 1970 UTC
payload_typestringenumeration data type for the payload. Possible values: STRING, INT, BINARY
payloaddepends on payload_type parameterThis is data object which IoT devices publishes. Can be everything as long as it comforts JSON standard

Example response

[{"rid":"example_rid","timestamp":"1424427183946","payload_type": "INT",payload: 1}]