I had some difficulty finding simple examples of how to use the Reolink API and ended up digging through some python implementations to figure out how it works.
The official documentation is available at https://bit.ly/3rWxG6e but it is a bit lacking, and the API is somewhat weird, which makes it difficult. You should still look at it though, as it lets you know what commands are available through the API.
The main weirdness is that even if you are sending one command at a time, the payload has to be an array of objects and the response is always an array of objects. Also, you have to pass the command both as a URL parameter and in the payload.
Included here are a small(ish) bash script (also requires jq) for running API commands against Reolink cameras or NVRs.
How to set differents privacy masks for each PTZ Preset (PTZ cameras AI and NON-AI)
For those which had a PTZ camera with PTZ Presets, generally you need to redefine your privacy mask to suit with your image of the preset and it's boring.
Here the method, with @jasonk script, how you can apply a new privacy mask after moving to a preset (without losing the others privacy masks) :
Example : I have 3 presets (id1: -preset garage-, id2 : -preset entrance- and id:3 -preset road-)
For the first one which your have defined a privacy mask (in my example id:1 -garage-), launch the command bellow and save the result in a file called, for example, json_mask_id1 :
./rl-api GetMask '{"channel":0}' | jq '.' -c > json_mask_id1
Switch to the second preset -id:2- and redefined a new privacy mask, apply it, and and also launch the command to saved the result in a second file called json_mask_id2:
./rl-api GetMask '{"channel":0}' | jq '.' -c > json_mask_id2
Switch to the third preset -id:3- and do the same method like the second preset and save the result in a file called json_mask_id3.
After that, when you trigger PTZ Preset by id with the command (taken for @pixeldoc2000) and in my case the id:2 entrance-
./rl-api PtzCtrl '{"channel":0, "op":"ToPos", "id":2, "speed":32}
launch, after that previous command, the command dedicated to apply the privacy mask file for id:2 :
./rl-api SetMask $(cat json_mask_id2)
NB : all the files json_mask_idX are located in the same repository of the rl-api.sh executable.