NodeJS Module: node-dahua-api

tangent

IPCT Contributor
Joined
May 12, 2016
Messages
4,342
Reaction score
3,524
just forked the module and should work now with digest-auth. also added functions for file search and retrieval
streiten/node-dahua-api

tested on IPC-HFW5831E-Z5E with firmware version 2.622.0000000.18.R, Build Date: 2017-11-10
as the camera has no PTZ those functions are not tested
@nayr hasn't been active on the forum in a while, but may respond to a pull request.
 

Sitnalta

Young grasshopper
Joined
Apr 23, 2017
Messages
4
Reaction score
18
Would be nice if somebody could make a Home Assistant component from the github code :love:
 

tangent

IPCT Contributor
Joined
May 12, 2016
Messages
4,342
Reaction score
3,524
Would be nice if somebody could make a Home Assistant component from the github code :love:
You can use the Amcrest component (dahua makes amcrest). It looks like the developer may have been working off an old version of the HTTP API.
This is the most recent version of the API that's posted publicly that I'm aware of: https://s3.amazonaws.com/amcrest-files/Amcrest+HTTP+API+3.2017.pdf (v2.12)

Consider contacting the developers of the amcrest component with feature requests and giving them a link to the newer documentation.
 

Carver

n3wb
Joined
Dec 11, 2017
Messages
17
Reaction score
4
I'd like to trigger a "Lens Init". The API (V1.67) doesn't include a suitable CGI command.
Is it possible with node.js?

Best regards, Carver
 

Carver

n3wb
Joined
Dec 11, 2017
Messages
17
Reaction score
4
@tangent: Thanks, but there's also no Lens Init available. And to do that with node-dahua-api (if possible), I don't know the command.
 

tangent

IPCT Contributor
Joined
May 12, 2016
Messages
4,342
Reaction score
3,524
Things like snapshot (which uses the following url: http://<ip>/cgi-bin/snapshot.cgi?channel=1) now gets a

Error
ErrorID=5, Detail=Server internal error!
I'd go back to the Dahua HTTP API documentation (amcrest version linked above) and test the basic functions in your web browser.

I'm not sure if the nodejs code has been updated to use digest authentication which newer cameras and nvrs are using. You may have to manually make some changes.
 

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
I'd go back to the Dahua HTTP API documentation (amcrest version linked above) and test the basic functions in your web browser.

I'm not sure if the nodejs code has been updated to use digest authentication which newer cameras and nvrs are using. You may have to manually make some changes.
Yeah did that...a lot of those functions don't work any more. Like snapshot.cgi, getConfig?action=ChannelTitle, the odd one does though.

Looks like in this device, and others? they've changed the api. Using fiddler I think i managed to figure out they've gone to a RPC2 call where json is posted. ie I see now that I can call the RPC2 with a json string containing "method":"configManager.getConfig","params":{"name":"ChannelTitle"} (and a few more and it seems to replicate that function that used to be in the http api call for configManger?action=getConfig&name=ChannelTitle.

So people using this api may start encountering issues on different hardware
 

tangent

IPCT Contributor
Joined
May 12, 2016
Messages
4,342
Reaction score
3,524
Yeah did that...a lot of those functions don't work any more. Like snapshot.cgi, getConfig?action=ChannelTitle, the odd one does though.

Looks like in this device, and others? they've changed the api. Using fiddler I think i managed to figure out they've gone to a RPC2 call where json is posted. ie I see now that I can call the RPC2 with a json string containing "method":"configManager.getConfig","params":{"name":"ChannelTitle"} (and a few more and it seems to replicate that function that used to be in the http api call for configManger?action=getConfig&name=ChannelTitle.

So people using this api may start encountering issues on different hardware
What firmware version are you running? Unfortunately Dahua doesn't make the API publicly available anymore and only provides it to people who sign an NDA.
This combined with their disregard for the license terms of open source software are a bit irritating.
 

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand

eengineer

n3wb
Joined
Jul 17, 2018
Messages
14
Reaction score
7
Location
Europe
Did Nayr leave the forum? :(

I'm looking into getting both motion and IVS into MQTT messages for some of my cameras...
 

psycik

Getting the hang of it
Joined
Dec 9, 2015
Messages
221
Reaction score
37
Location
Wellington, New Zealand
Did Nayr leave the forum? :(

I'm looking into getting both motion and IVS into MQTT messages for some of my cameras...
I have a service that does it (docker/python service to mqtt - psyciknz/CameraEvents ), which can also send image content for notifications. But the snapshot function is not working for my particular unit.

And the only other issue it might have is getting the channel list for an nvr. But it still sends motion alerts out.
 

eengineer

n3wb
Joined
Jul 17, 2018
Messages
14
Reaction score
7
Location
Europe
I will test that tomorrow, buddy. Nice! We just installed a Dahua A46 as a baby monitor and it replaced a hacked Xiaomi Dafang running Dafang Hacks with the MQTT motion detection alerts... so I need something similar.
 

tangent

IPCT Contributor
Joined
May 12, 2016
Messages
4,342
Reaction score
3,524
Did Nayr leave the forum? :(

I'm looking into getting both motion and IVS into MQTT messages for some of my cameras...
He hasn't been active here in quite a while. He had a lot of more important things going on in his life.
 
Last edited:

wrybread

Pulling my weight
Joined
Sep 12, 2018
Messages
252
Reaction score
115
Location
San Francisco
Hi! Is there some way to get a list of presets by this API?
Yup!

http://<IP>/cgi-bin/ptz.cgi?action=getPresets&channel=0

My Dahua SD49225T-HN returns:

Code:
presets[0].Index=1
presets[0].Name=Whatever
presets[0].Type=0
presets[1].Index=2
presets[1].Name=Whatever Else
presets[1].Type=0
presets[2].Index=3
presets[2].Name=Whatever Else Again
presets[2].Type=0

etc
And I agree with you, very very useful.

Incidentally I found it in the Amcrest API, not the Dahua API, even though I'm using a Dahua camera...

https://s3.amazonaws.com/amcrest-files/Amcrest+HTTP+API+3.2017.pdf
 
Last edited:

trollmar

n3wb
Joined
Feb 9, 2017
Messages
25
Reaction score
0
I have a service that does it (docker/python service to mqtt - psyciknz/CameraEvents ), which can also send image content for notifications. But the snapshot function is not working for my particular unit.

And the only other issue it might have is getting the channel list for an nvr. But it still sends motion alerts out.
Hi cool!
Thx for sharing.

Maybe a stupid question but how do I install it on ..lets say ubuntu?
Gitclone it ..and then? ;-)
 

kmax1940

Young grasshopper
Joined
Sep 27, 2016
Messages
42
Reaction score
3
Anyone know if there is a way to enable / disable p2p via the api?
Also, is there a way to grab the QR code via api?

I am trying to create a web based playback experience similar to what the user gets if they are standing at the dvr.
Do you guys think this api is sufficient for that?
 
Top