[ONVIF] Foscam R2: how to get snapshot photo via REST API

@mstegeman thanks for the ONVIF add-on, and I can connect my Foscam R2 successfully.

I plan to add a chatbot connection via the Mozilla IoT-GW, so whenever there is a motion alert the camera will send a snapshot via the IoT-GW to a particular chat thread. I have a few questions:

  1. How to use the REST API to get a snapshot? After using local auth token, I can get a json file by href “/things/onvif-012345678901”, but I cannot access the photo itself “/media/onvif/onvif-012345678901/snapshot.jpg”. The error shows that my auth token can only access /things.

  2. In ONVIF, is there an alerts event? e.g. if the Foscam R2 detected a motion, it can trigger a snapshot?

Thanks in advance!

  1. To access the snapshot, you’ll have to use your user token, not a regular OAuth token. Only /things is accessible by OAuth tokens. To get your user token, you can either inspect the Authorization header of some of the network requests via your browser’s developer tools, or you could use something like this script.
  2. That’s a tricky question. ONVIF, in theory, supports events. However, I’ve yet to find a camera with proper support for motion/sound events.
1 Like