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 16:59]
nightfly
api [2023/07/22 12:19] (current)
nightfly
Line 19: Line 19:
 ====== Supported objects and methods list ====== ====== Supported objects and methods list ======
  
 +^ Object ^ Method ^ Parameters required ^ Action/Reply ^
 +| models     | getall       | array of all existing camera models  |
 +| storages   | getall       | array of available storages  |
 +|            | getstates |     | array of all storages states |
 +| cameras    | getall |     | returs array of all available cameras data |
 +|            | create | modelid + ip + login + password + active + storageid + description     | creates new camera |
 +|            | activate | cameraid     | sets some camera as active |
 +|            | deactivate | cameraid     | deactivates specified camera |
 +|            | setdescription | cameraid + description    | sets description for specified camera |
 +|            | delete | cameraid | deletes specified camera |
 +|            | isregistered | ip    | checks is some camera is registered by IP on NVR or not? |
 +| users      | getall |      | returns array of all available users data |
 +|            | create | login + password     | creates new limited user |
 +|            | changepassword login + password |      | changes password for some user |
 +|            | delete | login     | deletes existing user |
 +|            | isregistered | login     | checks is user registered or not |
 +|            | checkauth | login + password     | checks user credentials |
 +| acls       | getall |      | returns array of all available ACLs |
 +|            | getallcameras |      | returns array of all cameras ACLs |
 +|            | getallchannels |      | returns array of all per-channel ACLs |
 +|            | getchannels | login    | returns array of all channels available for user |
 +|            | getcameras | login    | returns array of all cameras available for user |
 +|            | assignchannel | login + channelid | assigns some channel to user with ACL |
 +|            | assigncamera | login + cameraid    | assigns camera to user with ACL |
 +|            | deassignchannel | login + channelid    | deletes channel ACL for some user |
 +|            | deassigncamera | login + cameraid     | deletes camera ACL for specified user |
 +| channels   | getall |      | returns array of all available channels |
 +|            | getscreenshotsall |      | returns array of all available channel screenshots |
 +|            | getscreenshot | channelid     | returns specified channel screenshot path |
 +|            | getlivestream | channelid     | returns live preview stream URL |
 +| recorders  | getall |      | returns array of all running cameras recorders processes |
 +|            | isrunning | cameraid      | check is recorder running for some camera or not |
 +| system     | gethealth |      | returns array of basic system health parameters |
  
-^ Object ^ Method ^ Parameters required ^ 
-| models     | getall    -   | 
-| storages   | getall    -   | 
-|            | getstate |  -   | 
-| cameras    | getall |  -   | 
-|            | create | modelid + ip + login + password + active + storageid + description     | 
-|            | activate | cameraid     | 
-|            | deactivate cameraid |      | 
-|            | setdescription |  cameraid + description    | 
-|            | delete | cameraid | 
-|            | isregistered | ip    | 
-| users      | getall |      | 
-|            | create | login + password     | 
-|            | changepassword login + password |      | 
-|            | delete | login     | 
-|            | isregistered | login     | 
-|            | checkauth | login + password     | 
-|            |  |      | 
-|            |  |      | 
-|            |  |      | 
-|            |  |      | 
  
 +====== Usage examples ======
  
 +===== Models list =====
 +**Request**
  
 <code> <code>
-models: +http://yourhost.com/wr/?module=remoteapi&key=WRxxxxxxxxxxxx&action=rest&models=getall 
- getall+</code>
  
-storages: +**Reply** 
- + getall +<code> 
- + getstate+Array 
 +
 +    [12] => Array 
 +        ( 
 +            [id] => 12 
 +            [modelname] => Unv 
 +            [template] => UNV_IPC2122LB-SF28-A 
 +        )
  
-cameras: +    [11=> Array 
- + getall +        ( 
- + create [modelid + ip + login + password + active + storageid + description+            [id=> 11 
- + activate [cameraid] +            [modelname=> Hikvision DS-2CD1023G0E-I 
- + deactivate [cameraid+            [template=> Hikvision_DS-2CD1023G0E-I 
- + setdescription [cameraid + description+        )
- + delete [cameraid+
- + isregistered [ip]+
  
-users: +    [10=> Array 
- + getall +        ( 
- + create [login + password+            [id=> 10 
- + changepassword [login + password+            [modelname=> Tyto IPC-5D28-KS-30 
- + delete [login+            [template=> Tyto_IPC-5D28-KS-30 
- + isregistered [login+        ) 
- + checkauth [login + password]+.... 
 +</code>
  
-acls: +===== Wrong object or method =====
-  + getall +
-  + getallcameras +
-  + getallchannels +
-  + getchannels [login] +
-  + getcameras [login] +
-  + assignchannel [login + channelid] +
-  + assigncamera [login + cameraid] +
-  + deassignchannel [login + channelid] +
-  + deassigncamera [login + cameraid] +
-   +
-channels: +
-  + getall +
-  + getscreenshotsall +
-  + getscreenshot [channelid] +
-  getlivestream [channelid]+
  
-recorders: +**Request**
-  + getall +
-  + isrunning [cameraid]+
  
-system+<code> 
- + gethealth  +http://yourhost.com/wr/?module=remoteapi&key=WRxxxxxxxxxxxx&action=rest&wrongobject=getall 
 +</code>
  
 +**Reply**
 +<code>
 +Array
 +(
 +    [error] => 1
 +    [message] => "No object specified"
 +)
 </code> </code>
 +
 +
 +
 +**Request**
 +
 +<code>
 +http://yourhost.com/wr/?module=remoteapi&key=WRxxxxxxxxxxxx&action=rest&users=wrongmethod
 +</code>
 +
 +**Reply**
 +<code>
 +Array
 +(
 +    [error] => 2
 +    [message] => "Method not exists"
 +)
 +</code>
 +
 +
 +===== Storages list =====
 +
 +**Request**
 +<code>
 +http://yourhost.com/wr/?module=remoteapi&key=WRxxxxxxxxxxxx&action=rest&storages=getall
 +</code>
 +
 +**Reply**
 +<code>
 +Array
 +(
 +    [13] => Array
 +        (
 +            [id] => 13
 +            [path] => /mnt/nfs_disk3/wrstorage2
 +            [name] => NFS mounted storage
 +        )
 +
 +    [1] => Array
 +        (
 +            [id] => 1
 +            [path] => /wrstorage
 +            [name] => Default
 +        )
 +
 +)
 +</code>
 +
 +
 +===== Storages states =====
 +
 +**Request**
 +<code>
 +http://yourhost.com/wr/?module=remoteapi&key=WRxxxxxxxxxxxx&action=rest&storages=getstates
 +</code>
 +
 +**Reply**
 +<code>
 +Array
 +(
 +    [13] => Array
 +        (
 +            [state] => 1
 +            [total] => 968792403968
 +            [used] => 639428460544
 +            [free] => 329363943424
 +        )
 +
 +    [1] => Array
 +        (
 +            [state] => 1
 +            [total] => 31183237120
 +            [used] => 28042903552
 +            [free] => 3140333568
 +        )
 +
 +)
 +
 +</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
 +                )
 +
 +            [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
 +                )
 +
 +        )
 +
 +    [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]].
 +
api.1683554373.txt.gz · Last modified: 2023/05/08 16:59 by nightfly