Introduction
The OdontologyApp API is a RESTful API built with SvelteKit that provides programmatic access to dental clinic management features. The API enables you to manage patients, appointments, treatments, inventory, and administrative functions.Base URL
All API requests are made to endpoints under the/api path:
Request Format
All API requests must:- Use the appropriate HTTP method (GET, POST, PUT, PATCH, DELETE)
- Send JSON payloads for POST, PUT, and PATCH requests
- Include the
Content-Type: application/jsonheader for requests with a body - Include authentication cookies (session-based authentication)
Example Request
Response Format
All API responses are returned in JSON format with the following structure:Successful Response
Error Response
Available Endpoints
The API is organized into the following resource groups:Authentication
POST /api/auth/login- User loginDELETE /api/auth/login- User logout
Patients
GET /api/patients- List patientsPOST /api/patients- Create patientGET /api/patients/[id]- Get patient detailsPUT /api/patients/[id]- Update patientDELETE /api/patients- Delete patient
Appointments
GET /api/appointments- List appointmentsPOST /api/appointments- Create appointmentGET /api/appointments/[id]- Get appointment detailsPUT /api/appointments/[id]- Update appointmentDELETE /api/appointments/[id]- Delete appointmentGET /api/appointments/reminders- Get appointment reminders
Treatments
GET /api/treatments- List available treatments/servicesPOST /api/treatments- Create treatment (admin only)PUT /api/treatments- Update treatment (admin only)DELETE /api/treatments- Delete treatment (admin only)
Inventory
GET /api/inventory- List inventory itemsPOST /api/inventory- Create inventory itemPATCH /api/inventory- Update stock levels
Dashboard
GET /api/dashboard/stats- Get dashboard statisticsGET /api/dashboard/alerts- Get system alerts
Administrative
GET /api/users- List users (admin only)GET /api/branches- List clinic branchesGET /api/doctors- List doctorsGET /api/logs- Get system logs (admin only)GET /api/reports/debts- Get debt reports
Security
GET /api/admin/security/my-permissions- Get current user permissionsGET /api/admin/security/permissions- List all permissions (admin only)
AI & Analytics
POST /api/ai/suggest- Get AI treatment suggestionsGET /api/analytics- Get analytics data
Rate Limiting
Currently, there is no rate limiting implemented on the API. However, it is recommended to implement reasonable request rates to avoid overwhelming the server.Pagination
Most list endpoints do not implement pagination by default. All results are returned in a single response. For endpoints that support filtering, use query parameters:Filtering and Query Parameters
Many endpoints accept query parameters for filtering:Search term for filtering results (used in patients, etc.)
Date filter in ISO format (YYYY-MM-DD) for appointments
Filter by doctor ID (use “all” for all doctors)
Filter by branch ID (use “all” for all branches)
Filter by status (e.g., “pending”, “completed”, “all”)
Permissions System
The API implements a role-based permission system:- Admin: Full access to all endpoints
- Doctor: Access to patient and clinical data
- Receptionist: Access to appointments and basic patient info
- User: Limited access based on assigned permissions
VIEW_PATIENTS, CREATE_PATIENTS, MANAGE_INVENTORY). See Authentication for more details.
Data Types
Common data types used throughout the API:- Dates: ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:mm:ss.sssZ)
- IDs: Integer primary keys
- UUIDs: String format for patient unique identifiers
- Prices: Decimal numbers (e.g., 150.00)
- Booleans: Standard JSON boolean (true/false)
Next Steps
Authentication
Learn how to authenticate API requests
Error Handling
Understand error responses and status codes
