Control Reolink RLC-423 with API

you don't need WireShark or any special software to track down the commands. Just open your camera in the Chrome Browser, and press Ctrl Shift i (or Cmd Shift i on a Mac); then click on the "Network" tab at the top. Then run your camera using the regular controls and you will see the corresponding network commands appear in the network list. You can then click on each one, and look at the other tabs, Header, Preview, Response

Just a quick look, I can see that the PTZ control, you POST to this address (substitute in your cameras IP address AAA, BBB, and then also your token)

along with the request payload; this is a payload to move to preset 1:
[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":1}}]

move to preset 2
[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":2}}]

move right
[{cmd: "PtzCtrl", action: 0, param: {channel: 0, op: "Right", speed: 32}}]

to get your token for the URL above, you need to post here:

with this payload (substituted in your username and password)
[{"cmd":"Login","action":0,"param":{"User":{"userName":"admin","password":"abcdefg"}}}]

the response that comes back has the token in the name field
[
{
"cmd" : "Login",
"code" : 0,
"value" : {
"Token" : {
"leaseTime" : 3600,
"name" : "75a35d0a5a30680"
}
}
}
]

all of these commands can be sent in javascript very easily like so:

var url="";
var json=[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":1}}];

/create request for shopify
var req=new XMLHttpRequest();

req.onreadystatechange=function(e) {
if(req.readyState==4) {
var showErrorTab=false;
if(req.status==200) {
console.log("response:"+req.responseText);
} else {
console.log("Error calling PtzCtrl");
}
}
}

req.open("POST",url);
req.setRequestHeader("Accept","application/json");
req.send(JSON.stringify(json));

This is some amazing work you did there.

How can I post commands?
curl? Could you give an example?
 
I figuered it out. Only thing that keeps me from moving along is the token.

I can get a token with a payload.
But how do I parse this token to the next payload I need to send?

Can I get around the token and only work with user/password?

Thanks
 
curl -d '[{"cmd":"Login","action":0,"param":{"User":{"userName":"admin","password":"<yourpw>"}}},{"cmd":"SetIsp","action":0,"param":{"Isp":{"channel":0,"antiFlicker":"Off","exposure":"Auto","gain":{"min":1,"max":60},"shutter":{"min":0,"max":83},"blueGain":128,"redGain":128,"whiteBalance":"Auto","dayNight":"Color","backLight":"DynamicRangeControl","blc":124,"drc":112,"rotation":0,"mirroring":0,"nr3d":1}}}]' <yourip>/api.cgi?cmd=Login

curl -d '[{"cmd":"Login","action":0,"param":{"User":{"userName":"admin","password":"<yourpw>"}}},{"cmd":"SetIsp","action":0,"param":{"Isp":{"channel":0,"antiFlicker":"Off","exposure":"Auto","gain":{"min":1,"max":60},"shutter":{"min":0,"max":83},"blueGain":128,"redGain":128,"whiteBalance":"Auto","dayNight":"Black&White","backLight":"DynamicRangeControl","blc":124,"drc":112,"rotation":0,"mirroring":0,"nr3d":1}}}]' <yourip>/api.cgi?cmd=Login


First for Color Mode
Second one for Black&White
 
you don't need WireShark or any special software to track down the commands. Just open your camera in the Chrome Browser, and press Ctrl Shift i (or Cmd Shift i on a Mac); then click on the "Network" tab at the top. Then run your camera using the regular controls and you will see the corresponding network commands appear in the network list. You can then click on each one, and look at the other tabs, Header, Preview, Response

Just a quick look, I can see that the PTZ control, you POST to this address (substitute in your cameras IP address AAA, BBB, and then also your token)

along with the request payload; this is a payload to move to preset 1:
[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":1}}]

move to preset 2
[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":2}}]

move right
[{cmd: "PtzCtrl", action: 0, param: {channel: 0, op: "Right", speed: 32}}]

to get your token for the URL above, you need to post here:

with this payload (substituted in your username and password)
[{"cmd":"Login","action":0,"param":{"User":{"userName":"admin","password":"abcdefg"}}}]

the response that comes back has the token in the name field
[
{
"cmd" : "Login",
"code" : 0,
"value" : {
"Token" : {
"leaseTime" : 3600,
"name" : "75a35d0a5a30680"
}
}
}
]

all of these commands can be sent in javascript very easily like so:

var url="";
var json=[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":1}}];

/create request for shopify
var req=new XMLHttpRequest();

req.onreadystatechange=function(e) {
if(req.readyState==4) {
var showErrorTab=false;
if(req.status==200) {
console.log("response:"+req.responseText);
} else {
console.log("Error calling PtzCtrl");
}
}
}

req.open("POST",url);
req.setRequestHeader("Accept","application/json");
req.send(JSON.stringify(json));

Thanks for this tip! Helped me integrate ptz
 
you don't need WireShark or any special software to track down the commands. Just open your camera in the Chrome Browser, and press Ctrl Shift i (or Cmd Shift i on a Mac); then click on the "Network" tab at the top. Then run your camera using the regular controls and you will see the corresponding network commands appear in the network list. You can then click on each one, and look at the other tabs, Header, Preview, Response

Just a quick look, I can see that the PTZ control, you POST to this address (substitute in your cameras IP address AAA, BBB, and then also your token)

along with the request payload; this is a payload to move to preset 1:
[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":1}}]

move to preset 2
[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":2}}]

move right
[{cmd: "PtzCtrl", action: 0, param: {channel: 0, op: "Right", speed: 32}}]

to get your token for the URL above, you need to post here:

with this payload (substituted in your username and password)
[{"cmd":"Login","action":0,"param":{"User":{"userName":"admin","password":"abcdefg"}}}]

the response that comes back has the token in the name field
[
{
"cmd" : "Login",
"code" : 0,
"value" : {
"Token" : {
"leaseTime" : 3600,
"name" : "75a35d0a5a30680"
}
}
}
]

all of these commands can be sent in javascript very easily like so:

var url="";
var json=[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"ToPos","speed":32,"id":1}}];

/create request for shopify
var req=new XMLHttpRequest();

req.onreadystatechange=function(e) {
if(req.readyState==4) {
var showErrorTab=false;
if(req.status==200) {
console.log("response:"+req.responseText);
} else {
console.log("Error calling PtzCtrl");
}
}
}

req.open("POST",url);
req.setRequestHeader("Accept","application/json");
req.send(JSON.stringify(json));


Hi and thank you for this vital info. I'm trying to have it work in groovy (Hubitat) and I get a login failed response. It is clear that there's something I don't get (no pun intended) about http post... Do you think you could tell me all that I'm missing or point me to the right direction? Here is my groovy code:

Code:
def getNewToken()
{
    def result = "no result"
    def password = "123456"
    def user = "admin"
    def deviceContent = "application/json" /"plain/text" /"application/x-www-form-urlencoded" /"application/json"
    def localDevicePort = port /80
    def body = ""
    def headers = ["cmd":"Login","action":0,"param":["User":["userName":"${user}","password":"${password}"]]]
    def uri = "http://${ip}/cgi-bin/api.cgi?cmd=Login&token=null

    headers.put("HOST", "$ip")
    headers.put("Content-Type", deviceContent)

    log.debug """
$uri
$headers
"""

    def requestParams =
        [
            uri:  uri,
            headers: headers
        ]
    try {
        httpPost(requestParams){response ->

            log.trace response.data
        }
    } catch (Exception e) {
        log.error "${e}"
        result = e
    }
    return result
}

And here is what I get:
trace[ { "cmd" : "Login", "code" : 1, "error" : { "detail" : "login failed", "rspCode" : -7 } } ]

I have checked user and password several times and even created a temporary simple set of credentials for test purpose, so it can't be where I'm doing things wrong. Let me know if you have any idea. Thank you.
 
Here's what I run on a Raspberry Pi as a bash script. I pass in the command I want and the number of seconds before the command stops, e.g. I can invoke it like:

Code:
./CommandPauseStop.sh ZoomInc 5

This will call Zoom Increment, wait 5 seconds, and then call Stop, which emulates a mouse button press on the Zoom In+ button on the GUI for 5 seconds.

Code:
#!/bin/bash

ReolinkToken=`curl -s GET "http://192.168.1.11/cgi-bin/api.cgi?cmd=Login&token=null" -d '[{"cmd":"Login","action":0,"param":{"User":{"userName":"admin","password":"1234567"}}}]' | jq -r '.[].value.Token.name'`

Cmd=$1
Pause=$2

curl -s POST "http://192.168.1.11/cgi-bin/api.cgi?cmd=PtzCtrl&token=$ReolinkToken" -d '[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"'$Cmd'","speed":32}}]'

sleep $Pause

curl -s POST "http://192.168.1.11/cgi-bin/api.cgi?cmd=PtzCtrl&token=$ReolinkToken" -d '[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"Stop"}}]'

It requires installation of the jq library to make parsing of the returned token easier.
 
The Reolink 423 PTZ can be controlled via OnVIF. Unfortunately, the OnVIF implementation provided by Blue Iris does not seem to work. However, I have gotten PTZ/Presets it to work via a program I've written. So, tell Blue Iris is can be done and they aren't doing it. If you are paying Blue Iris for support they should respond.

I am using an OnVIF library to send the commands to the 423. Therefore, I don't have the raw OnVIF command readily available. I can capture it, and I do expect to do that shortly. In the end OnVIF commands are just http commands, so.... If you are still interested (I know that this thread is old) remind me if I haven't responded within a week.
 
Here's what I run on a Raspberry Pi as a bash script. I pass in the command I want and the number of seconds before the command stops, e.g. I can invoke it like:

Code:
./CommandPauseStop.sh ZoomInc 5

This will call Zoom Increment, wait 5 seconds, and then call Stop, which emulates a mouse button press on the Zoom In+ button on the GUI for 5 seconds.

Code:
#!/bin/bash

ReolinkToken=`curl -s GET "http://192.168.1.11/cgi-bin/api.cgi?cmd=Login&token=null" -d '[{"cmd":"Login","action":0,"param":{"User":{"userName":"admin","password":"1234567"}}}]' | jq -r '.[].value.Token.name'`

Cmd=$1
Pause=$2

curl -s POST "http://192.168.1.11/cgi-bin/api.cgi?cmd=PtzCtrl&token=$ReolinkToken" -d '[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"'$Cmd'","speed":32}}]'

sleep $Pause

curl -s POST "http://192.168.1.11/cgi-bin/api.cgi?cmd=PtzCtrl&token=$ReolinkToken" -d '[{"cmd":"PtzCtrl","action":0,"param":{"channel":0,"op":"Stop"}}]'

It requires installation of the jq library to make parsing of the returned token easier.

Reboot also works as a command:

Code:
Cmd="reboot"

curl -s POST "http://192.168.1.11/cgi-bin/api.cgi?cmd=PtzCtrl&token=$ReolinkToken" -d '[{"cmd":"reboot","action":0,"param":{"channel":0,"op":"'$Cmd'","speed":32}}]'

I know that's repetitively redundant, but I don't know the API well enough to strip out the unnecessary bits. But it does reboot the camera!