Overview
ThegetParkingStatus endpoint returns the current status of all parking spots in the system. It automatically expires and clears reservations that have passed their expiration time before returning the data.
Endpoint
Authentication
CORS-enabled endpoint accessible from web applications. Configure allowed origins in production.Request
No parameters required. This is a simple GET request.Response
Array of parking spot objects
Unique spot identifier (e.g., “A-01”, “I-16”)
Current spot status:
0: Occupied1: Available2: Reserved
Latitude coordinate of the parking spot
Longitude coordinate of the parking spot
Description of the parking spot
ID of the zone this spot belongs to (e.g., “zone_1764307623391”)
Firestore timestamp of the last status change
Present only when status is
2 (Reserved). Contains:license_plate: Vehicle license plateexpires_at: Firestore timestamp of expirationduration: Reservation duration in minutes
Success Response
- 200 OK - Returns array of parking spots with current status
Error Response
- 500 Internal Server Error - Database or server error
Automatic Expiration Logic
The function checks all reserved spots (status === 2) for expiration:
- Expiration Check: Compares current time with
reservation_data.expires_at - Batch Update: If expired, updates spot to status
1(Available) and deletes reservation data - Immediate Response: Returns corrected status without waiting for next request
- Background Commit: Database updates are committed asynchronously using Firestore batch operations
Code Example
Response Example
Performance Considerations
- Batch Operations: Expired reservations are updated in a single batch commit for efficiency
- Real-time Cleanup: Expiration checks happen on every request, ensuring fresh data
- No Polling Required: Clients receive automatically corrected data
Related Endpoints
- Reserve Parking Spot - Create a reservation
- Release Parking Spot - Cancel a reservation
- Ingest Parking Data - Update spot status from sensors