Skip to main content

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:
http://localhost:5000
For production deployments, replace with your server’s domain.

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:
Content-Type: multipart/form-data

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:
flash("✅ Registro guardado correctamente", "ok")
return redirect(url_for("index"))

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:
ok
string
Success messages (e.g., ”✅ Registro guardado correctamente”)
error
string
Error messages (e.g., “⚠️ Debes subir una imagen”)

OCR Technology

The API uses a dual OCR approach for license plate detection:
  1. Primary: OpenAI GPT-4o-mini vision model for accurate plate extraction
  2. Fallback: Tesseract OCR if GPT-4o fails to detect a plate
Extracted plates are:
  • 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 at data/registros.csv with the following structure:
FieldDescription
idAuto-incremented record ID
fecha_horaTimestamp (YYYY-MM-DD HH:MM:SS)
matriculaExtracted license plate number
propietarioVehicle owner name
tipo_vehiculoVehicle type
observacionAdditional notes
imagenUploaded image filename
Images are stored in the 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

200
Success
Request succeeded, file downloaded, or page rendered
302
Redirect
Action completed, redirecting to another page
404
Not Found
Requested resource or file not found
500
Server Error
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

Build docs developers (and LLMs) love