Skip to main content

Introduction

The Conversor de Unidades REST API provides programmatic access to unit conversion functionality through a Flask web server. The API acts as a bridge between the frontend and the ICE (Internet Communications Engine) server running on port 10000.

Base URL

All API endpoints are relative to your Flask server URL:
http://localhost:5000/api
The base URL can be configured through environment variables:
  • HOST: Server host (default: localhost)
  • PORT: Server port (default: 5000)
The Flask server must be connected to the ICE server on port 10000 for the API to function properly.

Authentication

The API currently does not require authentication. All endpoints are publicly accessible.

Available Endpoints

The API provides three main endpoints:

Convert Units

Convert values between different units

Get Units

Retrieve available units for a category

Status

Check ICE server connection status

Supported Categories

The API supports conversion for four unit categories:
  • temperatura: Temperature units (Celsius, Fahrenheit, Kelvin)
  • longitud: Length/distance units (meters, kilometers, miles, feet)
  • peso: Weight/mass units (kilograms, pounds, grams)
  • velocidad: Speed/velocity units (km/h, mph, m/s)

Error Handling

The API uses standard HTTP status codes and returns errors in JSON format:

HTTP Status Codes

Status CodeDescription
200Request successful
400Bad request (invalid parameters, category, or unit)
404Route not found
500Internal server error
503Service unavailable (ICE server disconnected)

Error Response Format

All errors follow this consistent structure:
{
  "error": "Description of what went wrong"
}

Common Error Types

Returned when an invalid unit is specified for a category.Status Code: 400Example:
{
  "error": "Unidad inválida: yards not supported for longitud"
}
Returned when an unsupported category is requested.Status Code: 400Example:
{
  "error": "Categoría no reconocida: volumen"
}
Returned when the ICE server is not connected.Status Code: 503Example:
{
  "error": "Servidor ICE desconectado"
}
Returned when a non-numeric value is provided.Status Code: 400Example:
{
  "error": "Valor inválido: could not convert string to float"
}

Rate Limits

There are currently no rate limits implemented on the API.
This API is designed for development and testing. Consider implementing authentication and rate limiting for production deployments.

CORS Policy

The Flask server serves both the API and frontend from the same origin, so CORS is not configured. If you need to access the API from a different origin, you’ll need to configure CORS headers.

Next Steps

Convert Units

Learn how to perform unit conversions

Get Available Units

Discover which units are available

Build docs developers (and LLMs) love