User Tools

Site Tools


api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
api [2023/05/08 17:32]
nightfly
api [2026/05/19 01:45] (current)
nightfly [Read-only clients apps API]
Line 1: Line 1:
 ====== HTTP REST API ====== ====== HTTP REST API ======
  
-====== Basics ======+====== NVR management basics ======
  
  
Line 30: Line 30:
 |            | delete | cameraid | deletes specified camera | |            | delete | cameraid | deletes specified camera |
 |            | isregistered | ip    | checks is some camera is registered by IP on NVR or not? | |            | isregistered | ip    | checks is some camera is registered by IP on NVR or not? |
 +|            | isipportfree | ip+port   | checks is some camera IP+PORT free on NVR or not? |
 | users      | getall |      | returns array of all available users data | | users      | getall |      | returns array of all available users data |
 |            | create | login + password     | creates new limited user | |            | create | login + password     | creates new limited user |
Line 48: Line 49:
 |            | getscreenshotsall |      | returns array of all available channel screenshots | |            | getscreenshotsall |      | returns array of all available channel screenshots |
 |            | getscreenshot | channelid     | returns specified channel screenshot path | |            | getscreenshot | channelid     | returns specified channel screenshot path |
-|            | getlivestream | channelid     | returns live preview stream URL (not implemented yet) |+|            | getlivestream | channelid     | returns live preview stream URL |
 | recorders  | getall |      | returns array of all running cameras recorders processes | | recorders  | getall |      | returns array of all running cameras recorders processes |
 |            | isrunning | cameraid      | check is recorder running for some camera or not | |            | isrunning | cameraid      | check is recorder running for some camera or not |
Line 184: Line 185:
  
 </code> </code>
 +
 +
 +
 +===== Existing cameras list =====
 +
 +
 +**Request**
 +<code>
 +http://yourhost.com/wr/?module=remoteapi&key=WRxxxxxxxxxxxx&action=rest&cameras=getall
 +</code>
 +
 +**Reply**
 +<code>
 +Array
 +(
 +    [54] => Array
 +        (
 +            [CAMERA] => Array
 +                (
 +                    [id] => 54
 +                    [modelid] => 11
 +                    [ip] => 172.30.1.92
 +                    [login] => admin
 +                    [password] => SomePassword
 +                    [active] => 1
 +                    [storageid] => 1
 +                    [channel] => kiqgdmrbma1
 +                    [comment] => Here some camera description
 +                    [realport] => Here is camera RTSP port that depends template or custom port if set
 +                    [maxretention] => Here is maximum retention days limit or zero if no
 +                )
 +
 +            [TEMPLATE] => Array
 +                (
 +                    [DEVICE] => Hikvision DS-2CD1023G0E-I
 +                    [PROTO] => rtsp
 +                    [MAIN_STREAM] => /h264
 +                    [SUB_STREAM] => /h264
 +                    [RTSP_PORT] => 554
 +                    [HTTP_PORT] => 80
 +                    [SOUND] => 0
 +                )
 +
 +            [STORAGE] => Array
 +                (
 +                    [id] => 1
 +                    [path] => /wrstorage
 +                    [name] => Default
 +                )
 +               
 +            [OPTS] => Array
 +                (
 +                    [id] => 1
 +                    [cameraid] => 57
 +                    [rtspport] => 666
 +                    [keepsubalive] => 0
 +                    [maxretdays] => 0
 +                    [order] => 
 +                )   
 +
 +        )
 +
 +    [33] => Array
 +        (
 +        ....
 +</code>
 +
 +
 +===== User creation =====
 +
 +**Request**
 +<code>
 +http://yourhost.com/wr/?module=remoteapi&key=WRxxxxxxxxxxxx&action=rest&users=create
 +</code>
 +
 +**Request data**
 +<code>
 +$requestData=array(
 + 'login'=>'view666',
 + 'password'=>'PasswordHere'
 + );
 +</code>
 +
 +**POST variable 'data'**
 +<code>
 +
 +{"login":"view666","password":"PasswordHere"}
 +</code>
 +
 +**Reply**
 +<code>
 +
 +
 +Array
 +(
 +    [error] => 0
 +    [message] => Success
 +)
 +</code>
 +
 +===== Attempt to create existing user =====
 +
 +**Request**
 +<code>
 +http://yourhost.com/wr/?module=remoteapi&key=WRxxxxxxxxxxxx&action=rest&users=create
 +</code>
 +
 +**Request data**
 +<code>
 +$requestData=array(
 + 'login'=>'view666',
 + 'password'=>'PasswordHere'
 + );
 +</code>
 +
 +**POST variable 'data'**
 +<code>
 +
 +{"login":"view666","password":"PasswordHere"}
 +</code>
 +
 +**Reply**
 +<code>
 +Array
 +(
 +    [error] => 7
 +    [message] => User already exists
 +)
 +</code>
 +
 +
 +We hope it is clear how it works. You can also check out a sample implementation of this API at [[https://github.com/nightflyza/Ubilling/blob/master/api/libs/api.wolfrecorder.php|this link]].
 +
 +
 +====== Read-only clients apps API ======
 +
 +Works same way, but requires only login+password or login+authtoken(md5 hash of password) instead of WolfRecorder serial.
 +
 +You can set user credentials as raw GET variables or inside keys in "data" POST array.
 +
 +<code>
 +curl -s -X POST 'https://yourhost/wr/?module=remoteapi&action=clientrest&channels=getall' --data-urlencode 'data={"login":"admin","password":"demo"}'
 +</code>
 +
 +or
 +
 +<code>
 +curl -s -X POST 'https://yourhost/wr/?module=remoteapi&action=clientrest&channels=getall&login=admin&password=demo'
 +</code>
 +
 +
 +====== Supported objects and methods list ======
 +
 +^ Object ^ Method ^ Parameters required ^ Action/Reply ^cified user |
 +| channels   | getall |  login+password or login+authtoken   | returns array of all accessible by user channels info |
 +
 +
 +====== Usage examples ======
 +
 +===== Normal request =====
 +<code>
 +curl -s -X POST 'https://yourhost/wr/?module=remoteapi&action=clientrest&channels=getall' --data-urlencode 'data={"login":"admin","password":"demo"}'
 +</code>
 +
 +<code json>
 +{
 +
 +    "error":0,
 +    "channels":[
 +        {
 +            "id":"randomchannelid01",
 +            "comment":"Just test cam",
 +            "active":0,
 +            "recording":0,
 +            "mainstream":0,
 +            "substream":0,
 +            "screenshot":"skins/chanblock.gif"
 +        },
 +        {
 +            "id":"randomchannelid02",
 +            "comment":"Another cam",
 +            "active":1,
 +            "recording":1,
 +            "mainstream":1,
 +            "substream":0,
 +            "screenshot":"howl/chanshots/randomchannelid02.jpg"
 +        }
 +    ]
 +
 +}
 +</code>
 +
 +===== Wrong credentials =====
 +
 +<code>
 +curl -s -X POST 'https://yourhost/wr/?module=remoteapi&action=clientrest&channels=getall&login=admin&password=wrongpassword'
 +</code>
 +
 +<code>
 +{
 +
 +    "error":6,
 +    "message":"Wrong credentials"
 +
 +}
 +</code>
 +
 +
 +===== Wrong request format =====
 +
 +<code>
 +curl -s -X POST 'https://yourhost/wr/?module=remoteapi&action=clientrest&channels=getall'
 +</code>
 +
 +<code>
 +{
 +
 +    "error":3,
 +    "message":"Wrong request data"
 +
 +}
 +</code>
 +
  
  
api.1683556343.txt.gz ยท Last modified: 2023/05/08 17:32 by nightfly