You can control Agent using the local built-in server. Agent has a number of commands you can call to integrate with other systems and home automation. Some commands take an object ID ( oid displayed at the top of the edit device tab) and a type ID (ot) 1 = microphone, 2 = camera. To use these just call the local server with the URLs provided. You can also pass in a group name ton control multiple devices. Specify a group name on the devices under the General tab. There is an option in the server to setup Basic Authentication so your integration should support Basic Authentication if you are deploying it publicly.

There's also a python wrapper, agent-py available.

Some examples:

  • grab.jpg?oid=1&size=320x240 : return a still image of the camera resized to 320x240
  • grab.jpg?oids=1,2,3,4&size=640x320&maintainAR=true&backColor=255,0,0 : return a grid of 4 cameras resized to 640x320, maintaining aspect ratio for the images with a red background (RGB)
  • video.mjpg?oids=1,2,3&size=320x240 : return a grid of cameras in mjpeg form
  • video.mjpg?oids=1,2,3&size=640x50&maintainAR=true&backColor=0,255,0 : return a grid of cameras in mjpeg form with a green background.
  • video.mp4?oids=1,2,3&size=320x240 : return a grid of cameras in mp4 form (the first camera with audio provides the audio stream). You can also use video.webm. See server settings/ streaming to set the framerate.
  • audio.mp3?oid=1 (or .ogg or .wav) : return live audio from the specified microphone
  • ptz.cgi?oid=1&dir=1 call PTZ on the camera. Specify dir = 0 for center, 1 = left, 2=up left, 3 = up, 4 = up right, 5 = right, 6 = down right, 7 = down, 8 = down left, 9 = zoom in, 10 = zoom out, 11 = stop
  • ptz.cgi?oid=1&cmd=COMMAND : execute a command on the camera. COMMAND = the url encoded portion in the extended commands options from the PTZ2.xml file in Agent eg: ptz.cgi?oid=1&cmd=preset.cgi%3F-act%3Dgoto%26-number%3D0
  • command.cgi?oid=1&ot=2&cmd=alert : Trigger alert on the device. You can use any command (cmd) from: alert, detect, recordOnAlertOn, recordOnDetectOn, recordingOff, record, recordStop, alertOn/Off, snapshot, switchOn/Off, ftpPhotosOn/Off, ftpRecordingsOn/Off, cloudPhotosOn/Off, cloudRecordingsOn/Off, saveLocalOn/Off, applyScheduleToDevice, scheduleOn/Off
  • command.cgi?group=upstairs&cmd=switchOff - apply the switch off command to all devices in the group upstairs. Specify the group on the device under "Groups" on the General tab.
  • command.cgi?cmd=arm : Arm Agent (enable alerting). You can also use: disArm, allOn, allOff, applySchedule, stopCloudUploads, rtmpStop
  • command.cgi?cmd=rtmpStart&oid=1 : start RTMP broadcasting for the device to the endpoint setup in Agent streaming settings.
  • command.cgi?cmd=getObjects : return a JSON object describing the server and all devices
  • command.cgi?cmd=getObject&ot=2&oid=1 : return a JSON object describing the specified device
  • command.cgi?cmd=getStatus : return a JSON object with summary details for the server
  • command.cgi?cmd=ping : ping the server to check it is up. Responds with {"status":"OK"}
  • command.cgi?cmd=getProfiles : return a JSON object with available profiles for the server
  • command.cgi?cmd=record&ot=2&oid=1&tag=someone%20at%20the%20door : start recording and tag the recording with "someone at the door"
  • command.cgi?cmd=setProfile&ind=0 : apply the profile with an index of 0 (0=Home, 1=Away, 2=Night)
  • events.json?ot=1&oid=2&seconds=60 : return a JSON object with details of the device events over the last 60 seconds (seconds can be up to 600)
  • command.cgi?cmd=setobjectstate&ot=2&oid=1&state=Monitor : Set the working state of the device. Options are:
    • None - disabled
    • Monitor - enabled, no motion detection
    • Modect - enabled, record on detect (applies a simple detector if detector is None)
    • Redect - enabled, start recording, motion detection enabled (records until no motion is detected, applies a simple detector if detector is None)
    • Record - enabled, start recording, no motion detection (records until stopped)

New in v3.1.0.0+
  • q.json?cmd=getevents or q.json?cmd=getevents&oid=4&ot=2 : return a list of recordings for all devices or a specific device.
    • If you receive 400 events you will need to make another call to getevents passing in enddate=x where x is the last received timestamp in the array to retrieve the next 400.
  • filethumb.jpg?oid=3&fn=3_2021-01-19_10-37-50_961.jpg : return a thumbnail of the recording. The filename is from the "fn" property in the json from the getevents call (with the extension replaced with .jpg).
  • filethumb.jpg?oid=3&fn=3_2021-01-19_10-37-50_961_large.jpg : return a full size image of the recording. The filename is from the "fn" property in the json from the getevents call (with the extension replaced with _large.jpg).
  • streamfile?oid=3&ot=2&fn=3_2021-01-21_16-34-42_977.mkv : stream the file to the caller. The filename is from the "fn" property in the json from the getevents call. It is up to the calling application to provide playback facility.
  • q.json?cmd=getcameragrabs&oid=3&ot=2 : return a list of photos for the specific device.
    • If you receive 800 grabs you will need to make another call to getcameragrabs passing in enddate=x where x is the last received timestamp in the array to retrieve the next 800.
  • grabthumb.jpg?oid=3&fn=2021-01-19_12-22-55_125.jpg : return a small (320x240) version of the of the photo. The filename is from the "fn" property in the json from the getcameragrabs call.
  • grabimage.jpg?oid=3&fn=2021-01-19_12-22-55_125.jpg : return a full size version of the of the photo. The filename is from the "fn" property in the json from the getcameragrabs call.

New in v3.2.3.0+
  • q.json?cmd=addrecording&ot=2&oid=3&move=0&tags=blah&path=D:\test.mp4: add a recording to a device (useful for cameras that record themselves or cameras that can't be monitored by Agent). move parameter is 1 or 0 - 1 = delete original. Recording will be copied to the devices folder location within Agent.

New in v3.2.6.0+
  • q.json?cmd=addcamera&substream=rtsp%3A%2F%2Fsomeurl.com%3A554%2Ffeed&mainstream=rtsp%3A%2F%2Fsomeurl.com%3A554%2Ffeed2&username=admin&password=123&alerts=1&record=1&resize=0&raw=1&fps=20&name=camera%20name: add a network camera called "camera name" with a live and a record url set, record on detect enabled and raw recording enabled. All fields are optional.
New in v3.2.8.0+
  • video.gif?oid=1&size=640x480&secs=10&framerate=5: Generate an animated gif from the live camera stream lasting 10 seconds running at 5fps.

New in v3.3.1.0+
  • command.cgi?cmd=restart: Restart the Agent DVR application.
  • command.cgi?oid=3&ot=2&cmd=triggerlpr: Trigger License Plate Recognition (LPR).

Url options

You can open Agent to a specific view by calling the Agent url with (case sensitive):

  • ?start=Live&viewIndex=3 (live view on view 3)
  • ?start=TimeLine (timeline view)
  • ?start=Photos (photos view)
  • ?start=Recordings (recordings view)
  • ?start=Floorplans&planIndex=2 (floorplans view on plan 2)
  • ?start=VR (virtual reality)
Authentication

By default Agent runs the local server without authentication (as remote access is secured behind our SSL hosted login page). You can enable Basic Authentication in Server Settings - Local Server tab by setting a Username and Password and checking Protect API. Your integration should detect an authentication challenge response from the server and prompt for credentials if needed.