total_slots = 9999) so that no date is ever genuinely unavailable. If a visit record for a given date does not exist yet, the POST /create/ endpoint creates it automatically.
This is a simplified scheduling system. Capacity enforcement exists in the model but is not enforced in practice —
total_slots is intentionally set to 9999 to allow unlimited selections for any date.Endpoints
| Method | Path | Auth | Description |
|---|---|---|---|
GET | /api/visits/ | Public | List all visits |
GET | /api/visits/available/ | Public | List visits with open slots |
POST | /api/visits/create/ | Public | Create visit or return existing for date |
GET | /api/visits/by_day/?date=YYYY-MM-DD | Public | Look up a visit by exact date |
GET | /api/visits/{id}/ | Public | Retrieve a single visit |
PUT | /api/visits/{id}/update/ | Admin | Update a visit record |
DELETE | /api/visits/{id}/delete/ | Admin | Delete a visit record |
GET /api/visits/
Returns all visit records, ordered by date descending.GET /api/visits/available/
Returns visit records whereavailable_slots > 0. Each object includes the computed available_slots field.
Response fields
Array of visit objects with open capacity.
Count of visit records returned.
POST /api/visits/create/
Creates a new visit for a date, or returns the existing visit if one already exists for that date. This endpoint is public and is called automatically by the anonymous purchase flow. Idempotent behavior: if a visit already exists for the givenday, the server returns 200 OK with the existing record instead of creating a duplicate.
Request body
Visit date in
YYYY-MM-DD format.Override the default capacity. Omit to use the system default.
201 Created:
200 OK:
GET /api/visits/by_day/
Looks up a visit record by exact date. Returns404 if no visit exists for that date.
Query parameters
The visit date to look up, in
YYYY-MM-DD format.Model reference
| Field | Type | Description |
|---|---|---|
id | integer | Auto-generated primary key |
day | date | Visit date — unique per record |
total_slots | integer | Capacity ceiling, default 9999 |
occupied_slots | integer | Occupied count, starts at 0 |
| Property | Formula |
|---|---|
available_slots | total_slots - occupied_slots |
Slot methods (internal)
| Method | Description |
|---|---|
occupy_slots(n) | Increments occupied_slots by n if capacity allows; returns bool |
free_slots(n) | Decrements occupied_slots by n; raises ValueError if n > occupied_slots |
has_available_slots(n) | Returns True if at least n slots are free |
