Skip to content

API Notes

Nils Griswold-Steiner edited this page Mar 20, 2018 · 1 revision

WebSocket

Requires a mapping from devices to clients, i.e. map[deviceId]*Client.

Connection:

  • email
  • isAuthed
  • permissions
  • subsriptions

Message

{
    "subsription": "string",
    "operation": "ADD/REMOVE/UPDATE"
}

Path

/user/devices

Make sure to update the front-end before doing server logic (to avoid situations where the front-end hasn't been setup to handle temp/alarm updates for a specific device). But then the server would have to remove the new device if something goes wrong.

  • deviceId

ADD

REMOVE

/device/alarm

  • deviceId

UPDATE

Allow for nil values

  • temp

/device/history

  • deviceId

ADD

  • temp
  • time

REST

Endpoint

Many of these should send updates to certain WebSockets

/user

For creating users

POST

/user/devices

For managing a user's devices.

GET

Get all devices (for setup).

POST

  • Adding a device to a user.
  • Requires a WebSocket push to /user/device subscribers.

DELETE

  • Delete a device.
  • Requires a WebSocket push to /user/device subscribers.

/device

POST

  • For adding devices to the database.

PUT

  • For updating the name in the database.
{
    "name": "string"
}

/device/alarm

PUT

  • Allow for nil values.
  • Requires a WebSocket push to /device/alarm subscribers.

/device/history

GET

  • deviceId

This endpoint gets all history for a single device

POST

  • Requires a WebSocket push to /device/history subscribers.