Endpoint
Request
Headers
Must be set to
application/jsonBody Parameters
The category of units to convert. Must be one of:
temperatura- Temperature conversionslongitud- Length/distance conversionspeso- Weight/mass conversionsvelocidad- Speed/velocity conversions
The numeric value to convert. Can be an integer or floating-point number.Example:
100, 32.5, -40The source unit to convert from. Available units depend on the category:temperatura:
celsius, fahrenheit, kelvinlongitud: m, km, mi, ftpeso: kg, lb, gvelocidad: kmh, mph, msNote: Case-insensitive (converted to lowercase internally)The target unit to convert to. Must be a valid unit for the specified category (see
desde for available units).Note: Case-insensitive (converted to lowercase internally)Request Example
Response
Success Response (200 OK)
The converted value as a floating-point number.
Example
Error Responses
400 Bad Request - Invalid Category
400 Bad Request - Invalid Category
Returned when an unsupported category is provided.
400 Bad Request - Invalid Unit
400 Bad Request - Invalid Unit
Returned when an invalid unit is specified for the category. The error is thrown by the ICE server.
400 Bad Request - Invalid Value
400 Bad Request - Invalid Value
Returned when the valor parameter cannot be converted to a number.
503 Service Unavailable - Server Disconnected
503 Service Unavailable - Server Disconnected
500 Internal Server Error
500 Internal Server Error
Returned when an unexpected error occurs during conversion.
Conversion Examples
Implementation Details
The conversion logic is implemented in the ICE server backend (web_server.py:118-125). The Flask API routes the request through the client wrapper to the appropriate ICE method:
temperatura→cliente.convert_temperatura()→ ICEconvertirTemperatura()longitud→cliente.convert_longitud()→ ICEconvertirLongitud()peso→cliente.convert_peso()→ ICEconvertirPeso()velocidad→cliente.convert_velocidad()→ ICEconvertirVelocidad()
Edge Cases
Same Unit Conversion
While the frontend typically prevents same-unit conversions (e.g., celsius to celsius), the API will process these requests. The result will be the same as the input value.Negative Values
The API supports negative values, which is important for temperature conversions:Floating-Point Precision
The API returns raw floating-point results. The frontend typically formats these to 6 decimal places (app.js:129):Related Endpoints
Get Available Units
Retrieve valid units for a category
Check Connection Status
Verify ICE server connectivity