Introduction
The CoroNet License Plate Scanner API is a Flask-based REST API that provides endpoints for uploading vehicle images, automatically extracting license plate numbers using OCR, and managing vehicle registration records.Base URL
When running locally:Authentication
Currently, this API does not implement authentication mechanisms. All endpoints are publicly accessible. For production use, consider implementing:- API key authentication
- OAuth 2.0
- JWT tokens
- Rate limiting
Request Format
The API accepts requests in two formats:Form Data (Multipart)
Used for endpoints that accept file uploads:URL Parameters
Used for simple GET requests with path or query parameters.Response Format
The API uses different response types:HTML Redirects
Most endpoints return HTML redirects (HTTP 302) with flash messages for web browser interaction:JSON Data
For programmatic access, records are stored in CSV format and can be exported.File Downloads
CSV export endpoint returns downloadable files with proper content-disposition headers.Flash Messages
The API uses Flask’s flash message system with two categories:Success messages (e.g., ”✅ Registro guardado correctamente”)
Error messages (e.g., “⚠️ Debes subir una imagen”)
OCR Technology
The API uses a dual OCR approach for license plate detection:- Primary: OpenAI GPT-4o-mini vision model for accurate plate extraction
- Fallback: Tesseract OCR if GPT-4o fails to detect a plate
- Converted to uppercase
- Limited to alphanumeric characters and hyphens
- Truncated to 10 characters maximum
- Return “NO_DETECTADA” if extraction fails
Data Storage
Records are stored in CSV format atdata/registros.csv with the following structure:
| Field | Description |
|---|---|
| id | Auto-incremented record ID |
| fecha_hora | Timestamp (YYYY-MM-DD HH:MM:SS) |
| matricula | Extracted license plate number |
| propietario | Vehicle owner name |
| tipo_vehiculo | Vehicle type |
| observacion | Additional notes |
| imagen | Uploaded image filename |
uploads/ directory with timestamped filenames.
Error Handling
The API handles errors through:- Flash messages for user-facing errors
- Console logging for OCR failures
- Fallback mechanisms for plate detection
- File existence checks before deletion
Rate Limits
No rate limiting is currently implemented. For production use, implement rate limiting to prevent abuse.Common Status Codes
Request succeeded, file downloaded, or page rendered
Action completed, redirecting to another page
Requested resource or file not found
Internal server error during processing
Next Steps
Upload Plate
Learn how to upload images and create records
View Records
Retrieve all vehicle registration records
Delete Record
Remove records from the database
Download CSV
Export all records in CSV format
