If you are not familiar with the MQTT protocol, we suggest going through this wiki article.
For MQTT connection, host url api.iostash-239ca9.ingress-alpha.easywp.com
and port 1883
is to be used. IOStash MQTT API requires authentication for publishing and subscribing topics. Pass x-access-token
as the username and the device secret which is created during device creation as the password. Set client id to the deviceID
. While listening to data updates, set a unique name as client ID or else messages will be delivered with QoS 0 instead of QoS 1.
Publishing Data
To write data to IOStash from your device, data is to be converted into a JSON string and published to the topic:
/x-access-token/deviceID
For example, to save data to temperature & humidity data points we defined for the device we created, publish data as
{"temperature": VALUE, "humidity": VALUE}
to the device's MQTT topic. IOStash will persist the data and the connected realtime clients will receive the update. Also, if the topic x-access-token/deviceID/system
is subscribed, status of data write will be published.
Subscribing for Updates
To subscribe for updates from a device, simply subscribe to the device's topic: /x-access-token/deviceID
. Make sure that you have access to the device or IOStash will ignore the subscribe request.