Skip to content

Web services description

roleo edited this page Dec 5, 2022 · 21 revisions

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

Table of Contents

Links

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

Get links for stream and snapshot services

Snapshot

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

RES: high or low (default high)

WATERMARK: yes or no (default no)

FILE: name of the file you want to save in /tmp/sd/record/ (default returns image/jpeg)

Record

http://IP:8080/cgi-bin/record.sh?time=TIME

Start recording of a video TIME seconds long.

Privacy

http://IP:8080/cgi-bin/privacy.sh?value=VALUE

VALUE: on, off or status Set privacy on or off, or get the status. Privacy "on" means rtsp and snapshot disabled, privacy "off" means rtsp and snapshot enabled.

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)
baby_crying_detect yes/no Enable baby crying detection
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/status low/high/both N/A rtsp: use param1 to set resolution
onvif start/stop/status low/high/both yes/no onvif: use param1 to set resolution and param2 to set snapshot watermark (param2 is available only if action = start
wsdd start/stop/status N/A N/A wsdd: discovery for onvif service
ftpd start/stop/status busybox/pure-ftpd N/A ftpd: use param1 to set which daemon use
mqtt start/stop/status N/A N/A mqtt to send motion events to a broker
mp4record start/stop/status N/A N/A mp4record (yi program that saves mp4 videos)
all start/stop/status N/A N/A all above services

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?action=go_preset&num=NUMBER

NUMBER=preset number (required option).

Add preset

http://IP:8080/cgi-bin/preset.sh?action=add_preset&name=NAME

NAME=preset name (required option, no space char allowed).

Delete preset

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

NUMBER=preset number (required option).

Audio

Audio from the microphone is available with the rtsp stream. Audio to the speaker is sent through 2 web services.

Speak

http://IP:8080/cgi-bin/speak.sh?lang=LANG

LANG=language (en-US, en-GB, de-DE, es-ES, fr-FR, it-IT)

Add the message you want to speech in clear text in the payload and send it with the POST method.

Speaker

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

Add the raw audio in the payload and send it with the POST method. The format must be 8 KHz, 16 bit, mono (S16LE).

Wifi

Scan

http://IP:8080/cgi-bin/wifi.sh?action=scan

This method scans the wifi networks and returns the list.

Save

http://IP:8080/cgi-bin/wifi.sh?action=save

Add wifi credentials in the payload and send them with the POST method. The format must be a json:

{
"WIFI_ESSID": "network_essid",
"WIFI_PASSWORD": "password",
"WIDI_PASSWORD2": "confirmation password"
}