Reolink API CGI commands

Moderator: leecollings

Post Reply
klin34970
Posts: 3
Joined: Monday 15 July 2019 18:19
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Reolink API CGI commands

Post by klin34970 »

Hello everyone !
I wanted to share with you how I use Reolink in Domoticz.
So Here I'm.
Sorry if my english is not perfect.

I didn't know Reolink in the past, I was looking for Dlink, Hikvision, Foscam, etc.. and I saw the Reolink RLC-420 (2 pack).
For the price they are really good and I confirmed they do the job.
As you can see I bought 4.
Image

I was looking for the CGI commands and found only this :
How to Capture Live JPEG Image of Reolink Cameras via Web Browsers : https://support.reolink.com/hc/en-us/ar ... b-Browsers


I will show you how to use all cgi commands.

Introduction
First you need a token to auth.

Code: Select all

url = cgi-bin/api.cgi?cmd=Login&token=null
payload = [{"cmd":"Login","action":0,"param":{"User":{"userName":"youruser","password":"yourpassword"}}}]
When you got the token you can do whatever you want.
Exemple:

Code: Select all

url = cgi-bin/api.cgi?cmd=SetAlarm&token=azeazeaz65454
payload = [{"cmd":"SetAlarm","action":1,"param":{"Alarm":{"channel":0,"type":"md","sens":[{"beginHour":0,"endHour":23,"beginMin":0,"endMin":59,"id":0,"sensitivity":21},{"beginHour":23,"endHour":23,"beginMin":59,"endMin":59,"id":1,"sensitivity":21},{"beginHour":23,"endHour":23,"beginMin":59,"endMin":59,"id":2,"sensitivity":21},{"beginHour":23,"endHour":23,"beginMin":59,"endMin":59,"id":3,"sensitivity":21}]}}}]
You can get the url and payload with the browser console of any settings/commands.
Image

Script
PHP script to turn on/off email and push notifications: https://drive.google.com/open?id=1b-2iu ... hOGqW-T4vu
This script is made for my use and write in 5min. You can use others technologies or/and improve it for you use. First I wanted only email notifications and in a second time I added push notifications.


Practice
How I use my script on Domoticz.

My domoticz is installed on my synology, so my apache too.
I can access to my script by url:

Code: Select all

Turn on email
http://yoursynologyip:apacheport/?ip=ipofthecamera&method=enableMotionEmail&action=1
Turn off email
http://yoursynologyip:apacheport/?ip=ipofthecamera&method=enableMotionEmail&action=0
yoursynologyip = the ip of your syno or apache server if your apache is not on your syno.
apacheport = apache port.
ipofthecamera = ip of the camera, you need to associate the MAC adress to a static ip.



Create a virtual on/off switch and put the url on Action on and off
Image

Now you can do what you want.
When I leave my house all cameras notifications turn on with my mobile position or scenario.
Same when I come home.
Senior laravel & fullstack developer
irrintxi
Posts: 1
Joined: Monday 02 December 2019 23:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Reolink API CGI commands

Post by irrintxi »

Hi,

could you, please, explain how to get the token to auth?

I am quite lost.....
klin34970
Posts: 3
Joined: Monday 15 July 2019 18:19
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Reolink API CGI commands

Post by klin34970 »

You have to put the payload

Code: Select all

[{"cmd":"Login","action":0,"param":{"User":{"userName":"youruser","password":"yourpassword"}}}]
I'm using a tool Postman to requests URLs: https://www.getpostman.com/

Image

You must use a script to get the token automatically, it's expire in 3600s (5min)
Senior laravel & fullstack developer
Mauro
Posts: 1
Joined: Saturday 06 June 2020 15:19
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Reolink API CGI commands

Post by Mauro »

Hi,

your PHP script to turn on/off email and push notifications is no longer available at the provided link.
Can you please share it again?

Thanks!
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Reolink API CGI commands

Post by Nautilus »

This seem like a good python library for Reolink: https://github.com/fwestenberg/reolink

I wonder if it could be used to build a plugin for reolink cameras :)
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Reolink API CGI commands

Post by Nautilus »

Maybe this helps someone. Most of the calls can be made by setting username and passowrd directly in the url, no need to fetch a token first. Found this on reddit, posted by someone representing Reolink.
Camera HTTP API.doc
(303.29 KiB) Downloaded 1151 times
daniel12345
Posts: 1
Joined: Saturday 14 May 2022 15:12
Target OS: Windows
Domoticz version:
Contact:

Re: Reolink API CGI commands

Post by daniel12345 »

Hello,

You dont happen to know the URL you mentioned that contains the user and password already.

I don't want to have to go through applying for tokens, it would be nice just to send a command with details already in there.

I'm trying to control the lights and zoom from a python program.

And the token would be a pain.
http://IPC_IP/api.cgi?cmd=GetIrLights&token=TOKEN
Nautilus
Posts: 722
Joined: Friday 02 October 2015 12:12
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Finland
Contact:

Re: Reolink API CGI commands

Post by Nautilus »

I’m not sure whether it works with all commands but at least for fetching the snapshot:

Code: Select all

cgi-bin/api.cgi?cmd=Snap&channel=0&rs=1213abc&user=#USERNAME&password=#PASSWORD
and for fetching the alarm status:

Code: Select all

api.cgi?cmd=GetAiState&user=#USERNAME&password=#PASSWORD
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests