12-14-2018 07:38 PM
agree with much of what was posted here.
I'd also request that semantic versioning of the API be used, as well as autogenerated documentation. The API should be what the frontend talks to, just like any other api customer.
IMHO, taking this approach would help ensure that anything implemented in the GUI would be doable without the gui, or with a different gui.
12-25-2018 08:51 AM
It is extremely disappointing that API access or integrations for automation platforms like SmartThings or Home assistant are not a priority to Ubiquity. Considering the investment in this space that Ubiquity has made by hiring Paulus Schoutsen of Home Assistant. More and more folks are moving to UniFi Cameras as a replacent for several other platforms. It just seems that API integration would be a big win.
12-29-2018 06:10 AM
+1 Vote here as well.
Having the ability to access Protect recordings/triggers programmatically would be very helpful. Like the others I'm looking to take action with my HA system based on motion detection.
01-06-2019 02:20 PM
I really need this. Actually I found this feature so basic that I didn't review if the Unifi Protect series would have this. I had assumed it had. But now I am disappointed.
An HTTP GET request, MQTT or a simple bash script is absolutely necessary.
01-08-2019 12:20 AM
+1 from me.
Agree with everyone here that an API is a MUST, I want to be able to control (motion) recording ON/OFF and other things.
Please make the API a high priority feature.
01-08-2019 12:45 AM
I too need an API, or other means of automating against unifi-video & unifi-protect. (ssh commands or rest-api would be best)
I've seen someone that made an integration with mqtt to unifi-video, which seems quite nice, but I have no experience with mqtt, so for me rest or ssh commands would be easier.
Need to do:
* Switch between no record / record, on spesifc cameras from an external source like home-automation. (This way, recordings could be on when the home automation detects that we are not home)
* Get triggers on motion detection for each camera, with last motion date/time (would act as a motion sensor for home automation)
01-09-2019 09:36 AM - edited 01-09-2019 09:37 AM
+1 for API
I have a CloudKey 1 and ordered already a Cloud Key 2 together with 5 UniFi Cameras. I also have HomeMatic from EQ3 running since a few years along with iobroker to connect it to everything else (e.g. FritzBox). For iobroker, there is already a UniFi plugin that interfaces with the API of the UniFi networking product line and it would be really nice, if UniFi Protect could also be integrated. This would enable to arm the alarm system when all Smartphones left the house and also arm the motion detection and recording of UniFi Protect. It could then also be triggered by window and door sensors...
01-09-2019 12:49 PM
+1 for the API. As example applications:
- Turn on alerts if nobody is home (tie in with home automation/security system)
- Take snapshots if a door is opened
I think a solid API should also help internal development. Write the API first, than built frontends in JS for browser or built a mobile app and such using the API.
01-10-2019 09:37 AM
I wrote a script for Unifi Video to monitor the motion log in /var/log/unifi-video/motion.log and send events to MQTT, not sure if Protect has a similar log file in /var/log/unifi-protect/motion.log ?
01-10-2019 02:15 PM
I found log file on my Cloud Key Gen 2+.
It's located at /srv/unifi-protect/logs/events.cameras.log
It has a very different structure. But I think something can be done with this ;-)
01-10-2019 02:24 PM
Also by digging around I found that the Cloud Key Gen 2+ is running Postgres.
Events are recorded there in table "events" of database "unifi-protect".
unifi-protect=# select schemaname, tablename from pg_tables where tableowner = 'unifi-protect';
schemaname | tablename
public | alerts
public | partitions
public | sessionIDs
public | cameras
public | users
public | groups
public | events
public | backups
public | recordingFiles
public | stats
public | thumbnails
public | recordingSchedules
public | nvrs
public | heatmaps
public | liveviews
public | notificationSchedules
01-10-2019 05:27 PM
Awesome I'm glad to see that Protect also has a way to monitor either the log or the database! Now we just need a script to monitor it and push it to an API (could be a curl call) or MQTT!
01-10-2019 05:54 PM
I just played a bit with it, and figured out part of the API, in particular enough to retrieve events.
First, to get basic information about the system (e.g. firmware version)
Next, to authenticate, send username and password (json encoded) to
you will get a JWT Bearer style authentication header back, that you need to include in later requests (in addition to a number of other items about the user.
next you need to request an access key. this key is required to get images later:
(no data, just the Authorization header from above)
to get a list of events:
GET /api/events?end=[unix timestamp]&start=[unix timestamp] &type=motion
this returns a list of events like:
To retrieve a thumbnail image for the event use the "thumbnail" parameter and request:
GET /api/thumbnails/[hex thumbnail id]?accessKey=[key returned from 'access-key' request above]
Also, to reboot a camera:
POST /api/camera/[hex cameraid]/reboot
01-10-2019 06:15 PM
01-11-2019 01:04 AM
In that case we could potentially use postgres triggers ( https://www.postgresql.org/docs/9.1/sql-createtrigger.html ) to get push notifications for new events.
(e.g. this npm package uses triggers to get live updates to queries on postgres: https://github.com/nothingisdead/pg-live-query ).
01-11-2019 08:36 AM