A RESTful API built with Flask for managing student fingerprint-based attendance tracking. It supports role-based access control via JWT and API key authentication.
- Python 3.10+
- PostgreSQL
pip
git clone https://github.com/davidleonstr/fingerprints-api.git
cd fingerprints-apipython -m venv venv
# Linux / macOS
source venv/bin/activate
# Windows
venv\Scripts\activatepip install -r requirements.txtIf
requirements.txtis missing, install manually:pip install flask flask-sqlalchemy psycopg2-binary pydantic python-dotenv pyjwt bcrypt
Use this repository.
git clone https://github.com/davidleonstr/fingerprints-db.gitThe default config expects:
- User:
postgres - Password:
root - Host:
localhost - Port:
5432 - Database:
fingerprints
Create a .env file at the root of the project:
API_HOST='localhost'
API_PORT=9000
API_KEY='your-api-key-here'
SQLALCHEMY_DATABASE_URI='postgresql://postgres:root@localhost:5432/fingerprints'
SQLALCHEMY_TRACK_MODIFICATIONS=False
JWT_SECRET='your-jwt-secret-here'
PASSWORD_SALT='your-bcrypt-salt-here'To generate a bcrypt salt for PASSWORD_SALT, run:
import bcrypt
print(bcrypt.gensalt().decode('utf-8'))python main.pyThe server will start at http://localhost:9000 by default.
On a fresh database, you need to initialize the system by creating the owner interactor.
GET /v1/system/blank
x-api-key: your-api-key-hereReturns "true" if no interactors exist yet.
POST /v1/system/owner
x-api-key: your-api-key-here
Content-Type: application/json
{
"username": "owner",
"password": "your-password"
}This endpoint is only available when the system is blank and automatically assigns the highest-level role.
All endpoints (except /v1/status/) require an API key header:
x-api-key: your-api-key-here
Most endpoints also require a Bearer JWT token:
Authorization: Bearer <token>
To obtain a token:
POST /v1/auth/
x-api-key: your-api-key-here
Content-Type: application/json
{
"username": "owner",
"password": "your-password"
}| Level | Description |
|---|---|
| 1 | Read-only |
| 2 | Moderator |
| 3 | Admin |
| 4 | Owner |
| Resource | Base URL |
|---|---|
| Status | /v1/status/ |
| Auth | /v1/auth/ |
| System | /v1/system/ |
| Entities | /v1/entity/ |
| Interactors | /v1/interactor/ |
| Students | /v1/student/ |
| Roles | /v1/role/ |
| Permission Levels | /v1/permission-level/ |
| Attendance | /v1/attendance/ |
| Attendance Day Times | /v1/attendance-day-time/ |
| Attendance Methods | /v1/attendance-method/ |
| Fingerprints | /v1/fingerprint/ |
| Fingerprint Names | /v1/fingerprint-name/ |
| Fingerprint Types | /v1/fingerprint-type/ |
All resources support standard CRUD operations (GET, POST, PUT, DELETE) where applicable.