Stop struggling with Dahua HTTP APIs and messy responses.
pydahua is a clean, production-ready Python library that helps you interact with Dahua biometric and access control devices effortlessly.
β No manual API construction β Clean Python methods β Structured responses (no raw parsing headaches) β Built for real-world systems
Perfect for HRMS, attendance systems, access control, and automation tools.
from pydahua import DahuaAPI
dahua = DahuaAPI(
ip="http://192.168.1.100",
username="admin",
password="password"
)
# Fetch system info
print(dahua.get_system_info())
# Fetch attendance logs
print(dahua.fetch_attendance_logs())Thatβs it. You're connected.
Install from PyPI:
pip install pydahuaWorking directly with Dahua APIs is frustrating:
- Responses come in raw key-value format
- Authentication requires HTTP Digest handling
- Logs are hard to structure
- API endpoints are not intuitive
pydahua solves this by:
- π Handling HTTP Digest authentication internally
- π Converting raw responses into structured dictionaries
- π Converting logs into clean Python lists
- βοΈ Providing simple, readable methods
- β Validating inputs before sending requests
So you can focus on your applicationβnot reverse-engineering APIs.
- π Attendance Logs (fetch + structured parsing)
- π€ User Management (add / delete / fetch users)
- πͺͺ Access Card Enrollment & tracking
- βοΈ Device Configuration (network, system, language)
- π Time & Localization control
- π Device Operations (reboot, shutdown)
- π Structured API responses (no raw parsing)
- π HTTP Digest authentication support
This library is used in real systems to:
- Sync biometric attendance with backend systems
- Manage access control users and cards
- Process large volumes of attendance logs
- Automate device configuration
Tested with real Dahua biometric devices.
- HRMS / Employee Management Systems
- Attendance Tracking Systems
- Access Control Systems
- Security & Surveillance Integrations
system_info = dahua.get_system_info()
print(system_info)dahua.add_user(
username="john",
password="1234",
group="admin",
sharable=True,
reserved=False
)dahua.enroll_new_user(
card_name="John Doe",
card_no="123456",
user_id="JD1001",
password="Pass@123"
)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)dahua.set_system_time(
date="2025-10-18",
time="23:00:00"
){
"records": [
{
"card_no": "123456",
"card_name": "John Doe",
"attendance_state": "CheckIn",
"door": "1",
"create_time": "2025-01-18T09:12:33"
}
],
"found": 1,
"status_code": 200
}Works with Dahua devices that support:
magicBox.cgiconfigManager.cgiuserManager.cgirecordFinder.cgi
π Check your device API documentation to confirm compatibility.
get_system_info()get_serial_number()get_hardware_version()get_device_type()
add_user()delete_user()get_user_info()get_user_info_all()
enroll_new_user()get_control_card_rec()
fetch_attendance_logs()get_logs()
get_general_config()set_general_config()get_basic_config()set_basic_config()get_record_config()set_record_config()
get_system_time()set_system_time()get_language_config()set_language_config()
reboot_device()shutdown_device()
- Async support
- More endpoint wrappers
- Better error handling
- Webhook/event-based integrations
Contributions are welcome!
You can help with:
- Adding new API endpoints
- Improving documentation
- Writing usage examples
- Fork the repo
- Create a branch:
git checkout -b feature-name - Commit:
git commit -m "Add feature" - Push:
git push origin feature-name - Open a Pull Request
This project is licensed under the LGPL-3.0 License π https://www.gnu.org/licenses/lgpl-3.0.html
If this project helped you:
- β Star the repo
- π Report issues
- π Share with others
This library was built to simplify real-world Dahua device integrations.
If you're working with biometric or access control systems, pydahua will save you hours of effort.