HTTP API Documentation

Rest Api Documentation

Get Identities

Create Persistence Sessions

Get Data From Device

Send Data To Device

Get Device Information

Error Status Codes

Example how to Test Your application with Curl

Following example flow assumes that you have completed following steps:

1) Registered your applicationID at Kaltiot Smart IoT Console

2) Downloaded Kaltiot Smart Gateway SDK

3) Implemented your application on top of Kaltiot Smart Gateway SDK

4) Succesfully registered your application into Kaltiot Smart Gateway

5) You have curl command line tool (https://en.wikipedia.org/wiki/CURL)

First you need to retrieve RID. Easiest way to get RID is fetch it by customerId. CustomerId is the parameter which you used at your Kaltiot Smart Gateway SDK to do registration.  Your ApiKey can be found from Console's Credential page. Result is JSON array where the most recent RID is first element

 

curl "https://restapi.torqhub.io:443/rids/identities/customerId/<YOU CUSTOMER ID GOES HERE>?ApiKey=<YOUR API KEY GOES HERE>"


{"rids":[{"rid":"0b731092-ca78-11e5-a38b","timestamp":1454505264166},{"rid":"a1e87340-ca74-11e5-aa22","timestamp":1454503798605},{"rid":"01fff268-ca6a-11e5-beaa","timestamp":1454499235357},{"rid":"e9e92bd2-b573-11e5-a9b9","timestamp":1452194515491},{"rid":"4bd0a086-b543-11e5-a0b5","timestamp":1452173634407},{"rid":"00834a0c-b51b-11e5-a8b0","timestamp":1452156328202},{"rid":"3c2aea20-a890-11e5-8f8c","timestamp":1450777314287},{"rid":"c5bf172c-a7f3-11e5-aa8c","timestamp":1450710114120},{"rid":"df7f11f4-a7f2-11e5-84f2","timestamp":1450709727824},{"rid":"f793f938-a560-11e5-8ab2","timestamp":1450427159379}]}

 

Pick the first Rid from the response and use that to send messages to it. You should see the payload text at your device now

curl -d "payload=[{\"payload_type\":\"STRING\",\"payload\":\"<TEXT TO BE SENT>\"}]"  "https://restapi.torqhub.io/rids/<YOUR RID GOES HERE>?ApiKey=<YOUR API KEY GOES HERE>"

{"result":"EnRoute"}

If we want to listen messages real time, we have two optionts. First option is to create persistene web socket connection and then open connection to it. Benefit for this is that if you lose your web socket connection, you wont lose the messages that have been sent when web socket connection was down. Instead, you will receive all the messages once you re-establish the web socket connection. Second option is to just open web socket connection, but in this case you will lose the message if your web socket connection goes down. Now we go with first option where we first create persistent session and then using session id we open web socket connection to it.

curl -X POST "https://restapi.torqhub.io/rids/<YOUR RID GOES HERE>/data_stream?ApiKey=<YOUR API KEY GOES HERE>"

{"session_id":"9754bc303065ec77fe846773b30c0bb971575257"}

 

Take the session_id parameter from the response and use that in next curl command to open web socket connection.

curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: restapi.torqhub.io" -H "Origin:https://restapi.torqhub.io" "https://restapi.torqhub.io/rids/<YOUR RID GOES HERE>/data_stream/sessionId/<YOUR SESSION ID GOES HERE>?ApiKey=<YOUR API KEY GOES HERE>"

[{"rid":"0b731092-ca78-11e5-a38b","time":1455007843000,"id":"85EC4B89-33CA-4E62-A0D1-0454B9C3FAF3","payload_type":"STRING","payload":"65.010735,25.468914,0,0,0,0,0,1,0.0,0.0"}]▒[{"rid":"0b731092-ca78-11e5-a38b","time":1455007843000,"id":"85EC4B89-33CA-4E62-A0D1-0454B9C3FAF3","payload_type":"STRING","payload":"65.010735,25.468914,0,0,0,0,0,-1,0.0,0.0"}]