The Simple IoT server currently provides both Http and NATS.io APIs. We've tried to keep the two APIs a similar as possible so it is easy to switch from one to the other. The Http API currently accepts JSON, and the NATS API uses protobuf.
NOTE, the Simple IoT API is not final and will continue to be refined in the coming months.
For details on data payloads, it is simplest to just refer to the Go types which have JSON tags.
Most APIs that do not return specific data (update/delete) return a StandardResponse
/v1/nodes
/v1/nodes/:id
/v1/nodes/:id/parents
/v1/nodes/:id/points
/v1/nodes/:id/cmd
/v1/nodes/:id/not
/v1/auth
email
and password
as form values, and returns a JWT
Auth
tokenYou can post a point using the HTTP API without authorization using curl:
curl -i -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '[{"type":"value", "value":100}]' http://localhost:8080/v1/nodes/be183c80-6bac-41bc-845b-45fa0b1c7766/points
If you want HTTP authorization, set the SIOT_AUTH_TOKEN
environment variable
before starting Simple IoT and then pass the token in the authorization header:
curl -i -H "Authorization: f3084462-3fd3-4587-a82b-f73b859c03f9" -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '[{"type":"value", "value":100}]' http://localhost:8080/v1/nodes/be183c80-6bac-41bc-845b-45fa0b1c7766/points
NATS.io allows more complex and efficient interactions between various system components (device, cloud, and web UI). These three parts of the system make IoT systems inherently distributed. NATS focuses on simplicity and is written in Go which ensures the Go client is a 1st class citizen and also allows for interesting possibilities such as embedding in the NATS server in various parts of the system. This allows us to keep our one-binary deployment model.
The siot
binary embeds the NATS server, so there is no need to deploy and run
a separate NATS server.
For the NATS transport, protobuf encoding is used for all transfers and are defined here.
node.<id>
data.EdgeNode
structs that meets the specified id
and parent
.parent
can can optionally by specified by setting the message
payload to one of the following:
node.<id>.children
node.<id>.points
node.<id>.<parent>.points
tombstone
point type is
used to track if a node has been deleted or not.node.<id>.not
node.<id>.msg
node.<id>.file
(not currently implemented)
error