Skip to content

Rest API

seriousm4x edited this page Mar 13, 2024 · 5 revisions

This project is based on PocketBase, therefore you can use their API. You can check our the documentation here: https://pocketbase.io/docs/api-rules-and-filters/

To get better documentation than this wiki page: login to the admin dashboard at localhost:8090/_/ and click the "API Preview" button at the top right. You should get plenty examples on all things you can do. There is also filtering and much more.

Authentication

All routes require the "Authorization" header with jwt token. You can get the jwt token like this:

Users:

  • [POST] /api/collections/users/auth-with-password

Admins:

  • [POST] /api/admins/auth-with-password

With body:

{
  "identity": "username or email",
  "password": "password"
}

Some basic endpoints you might find useful:

  • [GET] /api/collections/devices/records returns first 30 devices
  • [GET] /api/collections/devices/records/:id returns single device by id
  • [PATCH] /api/collections/devices/records/:id updates single device with json body
  • [DELETE] /api/collections/devices/records/:id deletes single device by id

I've extended the default PocketBase API:

  • [GET] /api/upsnap/wake/:id wakes the device with given id
  • [GET] /api/upsnap/sleep/:id send device with given id to sleep using sleep-on-lan
  • [GET] /api/upsnap/reboot/:id wakes the device with given id
  • [GET] /api/upsnap/shutdown/:id shuts down the device with given id
  • [GET] /api/upsnap/scan scans the network for devices