Stop dealing with raw XML and complex COSEC APIs.
pycosec is a simple, production-ready Python library that lets you integrate COSEC biometric devices in minutes — not hours.
✔ No manual API calls ✔ No XML parsing ✔ Clean Python interface ✔ Works out of the box
Perfect for HRMS systems, attendance tracking, and biometric integrations.
from pycosec import COSECBiometric
device = COSECBiometric(
machine_ip="192.168.1.100",
port=80,
username="admin",
password="password"
)
# Fetch attendance logs
events = device.get_attendance_events(no_of_events=10)
print(events)That’s it. No complex setup.
Install from PyPI:
pip install pycosecOr install locally:
git clone https://github.com/KSreethul/pycosec.git
cd pycosec
pip install .Working directly with COSEC APIs is painful:
- XML responses are hard to parse
- API parameters are not intuitive
- Authentication handling is repetitive
- Every project ends up rewriting the same code
pycosec solves this by:
- 🔄 Converting XML → Python dictionaries
- 🔐 Handling authentication automatically
- ⚙️ Providing simple, readable methods
- ✅ Validating arguments before sending requests
So you can focus on building your application—not debugging device APIs.
- 👤 User Management (Add / Update / Delete users)
- 📊 Attendance Fetching (Punch logs, events)
- ⚙️ Device Configuration (Time, access control, alarms)
- 🔐 Credential Management (Fingerprint, card, face, palm)
- ⚡ Automatic XML Parsing → Python dict
- ✅ Argument validation before API calls
- 🔌 Works with COSEC HTTP API (Basic Auth)
This library is used in production systems to:
- Sync biometric attendance with HRMS
- Manage employee data on devices
- Handle large volumes of attendance logs efficiently
Tested with real COSEC devices in live environments.
- HRMS / Employee Management Systems
- Attendance Tracking Systems
- Access Control Automation
- Biometric Data Sync Services
user_count = device.get_user_count()
print(user_count)device.set_cosec_user(
user_id="1001",
ref_user_id=1,
name="John Doe",
user_active=True,
card1="1234567890",
enable_fr=True
)events = device.get_attendance_events(no_of_events=50)
print(events){
"user-id": "1001",
"event-id": "101",
"date": "2026-04-21",
"time": "09:12:33",
"message": "Successful"
}basic_config()finger_reader_parameter_configuration()enrollment_configuration()access_settings_configuration()alarm_configuration()date_and_time_configuration()door_features_configuration()system_timer_configuration()special_function_configuration()wiegand_interface()smart_card_format()
get_cosec_user()set_cosec_user()delete_cosec_user()enable_user_face_recognition()get_user_credential()get_user_credential_count()delete_cosec_user_credential()
get_attendance_events()
- Async support
- More API endpoint wrappers
- Webhook/event-based sync
- Improved error handling
Contributions are welcome!
You can help with:
- Adding new API endpoints
- Improving documentation
- Writing examples
- Fork the repository
- Create a branch:
git checkout -b feature-name - Commit changes:
git commit -m "Add feature" - Push:
git push origin feature-name - Open a Pull Request
Check issues labeled good first issue to get started.
This project is licensed under the LGPL-3.0 License 👉 https://www.gnu.org/licenses/lgpl-3.0.html
- GitHub: https://github.com/KSreethul/pycosec
- Issues: https://github.com/KSreethul/pycosec/issues
- PyPI: https://pypi.org/project/pycosec/
If this project helped you:
- ⭐ Star the repo
- 🐛 Report issues
- 🔁 Share with others
This library was built to solve real-world biometric integration problems.
If you're working with COSEC devices, pycosec will save you hours of work.