If you've ever worked with Dahua biometric or access control devices, you already know the pain:
- Complex HTTP APIs
- Digest authentication headaches
- Raw, unreadable responses
- Manual pagination & parsing
I faced the same challenges while building real-world HRMS and attendance systems.
So I built something to fix it
Introducing pydahua
pydahua is a Python library that makes interacting with Dahua biometric devices simple, clean, and developer-friendly.
GitHub: https://github.com/KSreethul/pydahua
What Problems Does It Solve?
Instead of writing low-level API calls like this:
- Constructing URLs manually
- Handling HTTP Digest authentication
- Parsing raw key-value responses
- Managing logs manually
You can now do everything with simple Python methods.
Quick Example
from pydahua import DahuaAPI
dahua = DahuaAPI(
ip="http://192.168.1.100",
username="admin",
password="password"
)
# Get system info
print(dahua.get_system_info())
# Fetch attendance logs
print(dahua.fetch_attendance_logs())
Thatβs it. No complexity.
Key Features
- Built-in HTTP Digest authentication
- Clean and structured API responses
- User management (add, delete, fetch)
- Access card enrollment
- Attendance log retrieval (with parsing)
- Device configuration support
- Device control (reboot, shutdown)
Real-World Use Cases
I built this while working on:
- HRMS systems
- Attendance automation
- Biometric integrations
- Access control solutions
If you're building something similar, this will save you hours (or days).
Example: Fetch Attendance Logs
from datetime import datetime
logs = dahua.get_control_card_rec(
card_no="123456",
start_time=datetime(2025, 1, 1, 0, 0, 0),
end_time=datetime(2025, 1, 18, 23, 59, 59)
)
print(logs)
Output (clean & structured)
{
"records": [
{
"card_no": "123456",
"card_name": "John Doe",
"attendance_state": "CheckIn",
"door": "1",
"create_time": "2025-01-18T09:12:33"
}
],
"count": 1
}
Why I Built This
Most biometric SDKs are:
- Either poorly documented
- Or locked behind enterprise systems
I wanted a simple, open-source solution that developers can plug into any system.
Installation
pip install pydahua
Supported Devices
Works with Dahua devices that support:
magicBox.cgiconfigManager.cgiuserManager.cgirecordFinder.cgi
Open Source β Contributions Welcome
If you're working with biometric systems, I'd love your feedback.
- Found a bug? Open an issue
- Need a feature? Suggest it
- Want to contribute? PRs are welcome
Final Thoughts
If you're building:
- HR software
- Attendance systems
- Access control tools
pydahua can save you a lot of time and frustration.
Give it a try and let me know what you think
Links
If you found this useful, consider starring the repo β it really helps!
Top comments (0)