Webhook API - IN-9408

I have a azure hosted api that accepts my webhook. What parameters are critical for this to work? There is woeful documentation on JSON produced form camera. Test page on clound says to add parameters but then says to remove for production?

Anyway to get to the snapshot photo based on the JSON produced?

Your camera can contact a webhook when an alarm was triggered. You can find some documentation here (your camera can use both the HTTP or MQTT protocol to contact the alarm server (in your case the hosted cloud service). The JSON payload is identical in both cases:

You can use a free platform like Node-RED to first test the function locally and make sure everything works as expected:

The function above only sends the alarm trigger and detected objects. A snapshot then has to be requested from your camera manually. Either send an HTTP GET request to one of those addresses - depending on the JPG resolution you need:

  • https://{camera address}:{camera webport}/snap.cgi?chn=11
  • https://{camera address}:{camera webport}/snap.cgi?chn=12
  • https://{camera address}:{camera webport}/snap.cgi?chn=13

To get a base64 encoded snapshot use the following HTTP GET request:

  • https://{camera address}:{camera webport}/param.cgi?cmd=getsnapshot

If you plan on using MQTT connect your camera to your MQTT broker and subscribe to the MQTT alarmserver topics status/alarm/triggered/triggers & alarm/triggered/objects and the base64 snapshot topic task/photoseries/snap/base64

appreciate the info! how can i get snapshot from instar cloud? i dont want to dmz my internal cameras

Hey,

to access the Cloud API you - currently - have to manually create an access token:

  • https://api.cloud.instar.de/api/v1/token?username=xxxx@email.com&password=xxxxxx

The user name and password are the email address and pass you use to login to your Cloud account.

NOTE: You need to make your email address and password URL-safe before using them in a URL query!

The token - currently - defaults to a 2h expiration time. And the response to the above request looks like this:

{
    "status": 0,
    "message": "ok",
    "data": {
        "token": "baa0187e7f92b7216ac5f75e10890fdf1dd74d48",
        "token_expiration_time": 1623754949
    }
}
Parameter name Type Description
status Int Error code, 0 means no errors happened
message String Error message
token String API token
token_expiration_time Int Token exipiration time, defaults to 2 hours

After getting the token you can use it to access the list of alarms for your account:

  • https://api.cloud.instar.de/api/v1/alarm/list?page_no=1&page_size=1&token=xxxxxx

The example above uses two queries page_no and page_size to limit the response size - in this case you only get the latest alarm event recorded. You can use the following queries to customize the API request:

Parameter Required Type Description
token Yes String You can get token by calling api User token
is_falsealarm No Int Get falsealarm video or not, its value must be one of them: 0/1. 0 means get alarm video, 1 means get falsealarm video. Note: only is_falsealarm equals 0, then the filter person, vehicle, animal and unknown can be set as filter, otherwise the result will be empty
is_viewed No Int Get viewed video or not, its value must be one of them: 0/1. 0 means unviewed video, 1 means get viewed video
is_locked No Int Get locked or not, its value must be one of them: 0/1. 0 means unlocked video, 1 means get locked video
is_starred No Int Get starred video or not, its value must be one of them: 0/1. 0 means unstarred video, 1 means get starred video
attr_link No Int Combine locked and starred or not, its value must be one of them: 0/1. 0 means the result including locked or starred, 1 means the result including locked and starred
person No Int Get video with person or not. its value must be 1. this means get video with person. Note: only is_falsealarm equals 0, then you can set this filter, otherwise, the result will be empty
vehicle No Int Get video with vehicle or not. its value must be 1. this means get video with vehicle. Note: only is_falsealarm equals 0, then you can set this filter, otherwise, the result will be empty
animal No Int Get video with animal or not. its value must be 1. this means get video with animal. Note: only is_falsealarm equals 0, then you can set this filter, otherwise, the result will be empty
unknown No Int Get video with unknown or not. its value must be 1. this means get video with unknown. Note: only is_falsealarm equals 0, then you can set this filter, otherwise, the result will be empty
object_link No Int Combine person, vehicle and animal or not, its value must be one of them: 0/1. 0 means the result including person or vehicle or animal (once they are set as above), 1 means the result including person and vehicle and animal (once they are set as above)
license No String License number
date No String The specific date, it will get all alarm of this day, eg: 2020-10-01. Note: if date is used, other date filter like start_date, end_date, start_time and end_time will be ignored
start_date No String Start date, eg: 2020-10-18
end_date No String End date, eg: 2020-11-20
start_time No String Start time: 08:00
end_time No String End time: 18:00
time_interval No Int Use time as a daily period of time, its value must be 0/1. 0 means ger all videos from start time of start date to end time of end date. 1 means only get this alarm videos between start time and end time of every day
cam_id No Int Camera id
camset_id No Int Camera set id. Note: if camera set id used, camera id will be ignored.
page_no No Int Page number
page_size No Int Page size

And a typical API response will look like:

{
    "status": 0,
    "message": "ok",
    "data": {
        "totalCount": 299,
        "totalPages": 299,
        "alarmList": [
            {
                "alarm_id": 1333410,
                "start": "2020-11-18 16:36:04",
                "cam_id": 482,
                "name": "New one",
                "object_detection": 0,
                "is_viewed": 0,
                "is_locked": 0,
                "is_starred": 0,
                "is_falsealarm": 1,
                "object": 3,
                "video": "https://api.cloud.instar.de/api/v1/video/alarm
/1333410.mp4",
                "video_poster": "https://api.cloud.instar.de/api/v1/poster/
alarm/1333410.jpg"
            }
        ]
    }
}
Parameter Type Description
status Int Error code, 0 means no errors happened
message String Error message
totalCount Int Total count of alarms
totalPages Int Total pages of alarms
alarmList String It is array, it includes all alarms list info, if there is no any alarms data, it will empty array
alarm_id Int Alarm id
start String The create time of alarm
cam_id Int Camera id
name String Camera name
object_detection Int If camera activated object detection or not, its value must be one of them: 0/1. 0 means deactivated, 1 means activated
is_viewed Int If alarm viewed or not, its value must be one of them: 0/1. 0 means unviewed, 1 means viewed
is_locked Int If alarm locked or not, its value must be one of them: 0/1. 0 means unlocked, 1 means locked
is_starred Int If alarm starred or not, its value must be one of them: 0/1. 0 means unstarred, 1 means starred
is_falsealarm Int If alarm is false alarm or not, its value must be one of them: 0/1. 0 means not false alarm, 1 means false alarm
object Int Which object detect in alarm video. its value must be one of them: -2/0/1/2/3/4/5/6/7, -2 means no object detection for alarm video, 0 means unknown, 1 means person, 2 means vehicle, 3 means person & vehicle, 4 means animal, 5 means person & animal, 6 means vehicle & animal, 7 means person, vehicle & animal. Note: only is_falsealarm equals 0, then object is valid.
video String Video link, need to added token after video link to access video. Like: https://api.cloud.instar.de/api/v1/video/alarm/1333410.mp4?token=xxxxx
video_poster String Video poster link, need to added token after video poster link to access the poster. Like: https://api.cloud.instar.de/api/v1/poster/alarm/1333410.jpg?token=xxxxxx

To download either the alarm snapshot or the entire alarm video you need to attach the generated token to your request:

  • https://api.cloud.instar.de/api/v1/video/alarm/1333410.mp4?token=xxxxxx
  • https://api.cloud.instar.de/api/v1/poster/alarm/1333410.jpg?token=xxxxxx
1 „Gefällt mir“

Thank you!! incredible documentation,

1 „Gefällt mir“