Skip to content

Web services description

roleo edited this page Nov 21, 2020 · 10 revisions

There are web services useful for many functions. The default format is JSON (or JPG for images).

Table of Contents

Snapshot

http://IP:8080/cgi-bin/snapshot.sh?res=RESOLUTION&watermark=WATERMARK

RES: high or low (default high)

WATERMARK: yes or no (default no)

Motion events management

List directories

http://IP:8080/cgi-bin/eventsdir.sh

List of directories containing registered mp4 files.

List files

http://IP:8080/cgi-bin/eventsfile.sh?dirname=2020Y01M01D01H

List of mp4 files contained in a specific directory.

Delete directories

http://IP:8080/cgi-bin/eventsdirdel.sh?dir=all

Remove all directories (containing registered mp4 files).

http://IP:8080/cgi-bin/eventsdirdel.sh?dir=2020Y01M01D01H

Remove directory /tmp/sd/record/2020Y01M01D01H (directory containing registered mp4 files).

Delete file

http://IP:8080/cgi-bin/eventsfiledel.sh?file=2020Y01M01D01H/00M00S60.mp4

Remove file /tmp/sd/record/2020Y01M01D01H/00M00S60.mp4

Get recorded videos

http://IP:8080/cgi-bin/getlastrecordedvideo.sh

Use. Available variables:

"oldness" variable. Defines which video to retrieve..

  • "0" (default) or "1" means latest already available.

  • greater than "0" specifies the oldness, so "3" means the third oldest video. Only looks into the current hour folder. So if value is greater than the videos in the latest hour folder, the last one will be sent.

  • negative value (e.g. "-1") means to wait for the next available video. Only works if a video is already being recorded, max. time to wait 80 seconds.

"type" variable. Defines what to retrieve.

  • "1" (default). Gets relative name in the format of DIR/VIDEO.mp4

  • "2". Gets full URL video.

  • "3". Gets the video itself as video/mp4 inline.

  • "4". Gets the video itself as video/mp4 attachment.

Examples of use:

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh?oldness=-1&type=4 -- Wait for a new video and sends it as an attachment.

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh?oldness=-1&type=3 -- Wait for a new video and shows it inline in the browser.

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh?type=1 -- Send the relative route of the last available video.

http://IP:PORT/cgi-bin/getlastrecordedvideo.sh?oldness=2&type=2 -- Send the URL of the second to last available video.

Configuration

Get configuration

http://IP:8080/cgi-bin/get_configs.sh?conf=CONF

CONF action
system Get system configuration
mqtt Get mqtt configuration
camera Get camera settings

Set configuration

http://IP:8080/cgi-bin/set_configs.sh?conf=CONF

CONF action
system Update system configuration
mqtt Update mqtt configuration
camera Update camera settings

Need POST mehod with a json file.

Get status info

http://IP:8080/cgi-bin/status.json

Get hostname

http://IP:8080/cgi-bin/hostname.js

Camera settings

http://IP:8080/cgi-bin/camera_settings.sh?conf=value

conf value action
switch_on yes/no Switch on/off the video on the camera
save_video_on_motion yes/no If enabled, video will be saved only when a motion is detected. If disabled, video will be always saved. (It takes effect only if recording is enabled)
sensitivity low/medium/high Detection sensitivity (low, medium or high)
led yes/no Set status led on or off
ir yes/no Enable IR led for night vision
rotate yes/no Enable image rotation for ceiling mount

Save settings on camera.conf and send IPC commands to the cam (no reboot is needed).

Maintenance

Load settings from file

http://IP:8080/cgi-bin/load.sh

Load configuration file (it requires post methid).

Save settings to file

http://IP:8080/cgi-bin/save.sh

Save configuration to a file.

Upgrade firmware

http://IP:8080/cgi-bin/fw_upgrade.sh?get=info

Get upgrade info.

http://IP:8080/cgi-bin/fw_upgrade.sh?get=upgrade

Start upgrade procedure.

Reboot the cam

http://IP:8080/cgi-bin/reboot.sh

Service start and stop

http://IP:8080/cgi-bin/service.sh?name=NAME&action=ACTION&param1=PARAM1&param2=PARAM2

name action param1 param2 description
rtsp start/stop low/high/both N/A Start rtsp: use param1 to set resolution
onvif start/stop low/high/both yes/no Start onvif: use param1 to set resolution and param2 to set snapshot watermark (param2 is available only if action = start
ftpd start/stop busybox/pure-ftpd N/A Start ftpd: use param1 to set which daemon use
mqtt start/stop N/A N/A Start mqtt to send motion events to a broker
mp4record start/stop N/A N/A Start mp4record (yi program that saves mp4 videos)

PTZ

Move manually

http://IP:8080/cgi-bin/ptz.sh?dir=DIRECTION&time=TIME

DIRECTION=left, right, up or down (required option).

TIME=period of movement (default 0.3 s).

Go to preset

http://IP:8080/cgi-bin/preset.sh?num=NUMBER

NUMBER=preset number (required option).