Authentication
API details
- Protocol:
wss:// - Endpoint:
wss://api.gridsense.cloud/ws/m/<organization>/c/<channel> - Headers:
- Authorization:
Client <device secret>
- Authorization:
For authorization, you may alternatively pass a query paramater like so:
wss://api.gridsense.cloud/ws/m/<organization>/c/<channel>?authorization=<device secret>
This proves useful in contexts where passing headers is not possible.
Example
We will use websocat to for simple demonstrations. For an example Python
script, see sending messages.
The topic in this example is m/<organization>/c/<channel>, where <organization>
and <channel> are the IDs of the organization and channel respectively. Alternatively,
the routes of the organization and channel can be used instead. For more on topics,
see topic structure.
# Connect to a specific channel. This allows us to both listen to and send messages.
$ websocat wss://api.gridsense.cloud/ws/m/<organization>/c/<channel>?authorization=<device secret>
# New messages will be shown here in the terminal.
# Send messages by simply typing them into the terminal:
[{"bn": "org/lighting/SmartLight/", "n": "brightness", "u": "lm", "v": 100}] # hit enter to send