The Predictions API exposes machine-learning forecasts for the FNC (Federación Nacional de Cafeteros) reference coffee price. Predictions are generated by CoffePrice’s hybrid ML pipeline and consumed by both producers and buyers to anticipate market movements. All read endpoints are public and require no authentication. Write endpoints (create, update, delete) are restricted to theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JaiderT/CoffeePrice/llms.txt
Use this file to discover all available pages before exploring further.
admin role.
Base URL: /api/predicciones
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /api/predicciones | None | All available predictions, ascending by date |
| GET | /api/predicciones/ultima | None | Single latest prediction |
| GET | /api/predicciones/resumen | None | Tomorrow’s prediction with a plain-text summary |
| GET | /api/predicciones/rango | None | Predictions for the last 7, 15, or 30 days |
| GET | /api/predicciones/dia | None | Prediction for today + N days (offset) |
| GET | /api/predicciones/fecha | None | Prediction for a specific calendar date |
| GET | /api/predicciones/:id | None | Single prediction by MongoDB ObjectId |
| POST | /api/predicciones | admin | Create a prediction |
| PUT | /api/predicciones/:id | admin | Update a prediction |
| DELETE | /api/predicciones/:id | admin | Delete a prediction |
Data sources
The API resolves predictions from two file-based sources before falling back to MongoDB:backend/datos/predicciones_fnc.json— the most recent prediction generated by the daily ML pipeline run. A single JSON object following the FNC hybrid model schema.backend/datos/historial_predicciones_fnc.csv— a cumulative CSV log of all past predictions produced by the pipeline. Grows with each daily run.
GET /api/predicciones
Returns all available predictions merged from the history CSV and the latest JSON file, sorted byfecha ascending. If no file data is available, falls back to MongoDB and returns all stored predictions.
Authentication: None — public, rate-limited.
Response
An array of prediction objects sorted by date ascending.Prediction object fields
The calendar date this prediction applies to, in
YYYY-MM-DD format.Estimated FNC price in Colombian pesos (COP) for the predicted date.
Lower bound of the prediction confidence interval, in COP.
Upper bound of the prediction confidence interval, in COP.
Direction of predicted price movement relative to the current day. One of
sube, baja, or estable.Model confidence score from
0 to 100. Derived from the selected strategy’s holdout MAPE using max(45, min(90, round(92 - (mape * 10)))). Falls back to 65 when MAPE is not a finite number. Fixed at 92 when preciominimo === preciomaximo (point prediction with no interval).Identifier of the model that produced this prediction. Typically
fnc_hibrido.Data source identifier. One of
fnc_hibrido_json (from the latest JSON file), fnc_hibrido_historial (from the history CSV), or mongo (from MongoDB).Human-readable plain-text summary of the prediction, in Spanish. Built from
tendencia and confianza, or taken directly from explicacion if available.Timestamp when the ML pipeline generated this prediction.
Percentage change between the current FNC price and
precioestimado.Base forecasting strategy used by the model (e.g.,
media_movil, regresion).Mean Absolute Percentage Error measured on the model’s holdout validation set.
Mean Absolute Error measured on the model’s holdout validation set, in COP.
Optional free-text model explanation. When present, used directly as
mensaje.Example request
Example response
GET /api/predicciones/ultima
Returns the single most recent prediction available. Reads frompredicciones_fnc.json first; falls back to the latest MongoDB document if the file is absent or invalid.
Authentication: None — public, rate-limited.
Responses
| Status | Description |
|---|---|
| 200 | Latest prediction object. |
| 404 | No predictions available from any source. |
Example request
Example response
GET /api/predicciones/resumen
Returns the prediction for the next trading day accompanied by a plain-text message in Spanish. This endpoint is designed for dashboard summaries and push notification payloads. Authentication: None — public, rate-limited. Themensaje field is determined by tendencia and confianza:
tendencia | confianza | mensaje |
|---|---|---|
sube | ≥ 70 | ”Se proyecta una subida del precio del cafe en la proxima jornada.” |
sube | < 70 | ”Hay senales de una posible subida en el precio del cafe.” |
baja | ≥ 70 | ”Se proyecta una baja del precio del cafe en la proxima jornada.” |
baja | < 70 | ”Hay senales de una posible baja en el precio del cafe.” |
estable | ≥ 70 | ”Se espera estabilidad en el precio del cafe para la proxima jornada.” |
estable | < 70 | ”El precio del cafe podria mantenerse estable en la proxima jornada.” |
explicacion is set on the prediction, it overrides the generated message.
Responses
| Status | Description |
|---|---|
| 200 | Prediction summary for the next trading day. |
| 404 | No prediction available for tomorrow. |
Example request
Example response
GET /api/predicciones/rango
Returns a slice of the available prediction series covering the lastdias entries. Useful for rendering trend charts on producer and buyer dashboards.
Authentication: None — public, rate-limited.
Query parameters
Number of days to include in the response. Must be one of
7, 15, or 30. Any other value returns a 400 error.Responses
| Status | Description |
|---|---|
| 200 | Ranged prediction envelope. |
| 400 | dias is missing or not one of 7, 15, 30. |
| 404 | No predictions available for the requested range (MongoDB fallback only). |
Response fields
The requested range value as provided in the query parameter.
Actual number of prediction records returned. May be less than
dias if the history is shorter.generatedAt value taken from the last prediction in the returned slice.modelVersion taken from the last prediction in the returned slice.Source identifier.
fnc_hibrido_historial when served from files; mongo when served from the database fallback.prediccion_unica when only one result is available; historial_fnc otherwise.Contextual note about the data. Indicates whether the data comes from real historical runs or a live database projection.
Array of prediction objects. See Prediction object fields above.
Example request
Example response
GET /api/predicciones/dia
Returns the prediction for a date calculated as today (Bogotá timezone) +offset days.
Authentication: None — public, rate-limited.
Query parameters
Number of days ahead of today to look up. Must be one of
1, 7, 15, or 30. Any other value returns a 400 error.Responses
| Status | Description |
|---|---|
| 200 | Prediction for the target date, prefixed with the offset value. |
| 400 | offset is missing or not one of the allowed values. |
| 404 | No prediction found for the computed date. |
Example request
Example response
GET /api/predicciones/fecha
Returns the prediction for a specific calendar date provided as a query parameter. Authentication: None — public, rate-limited.Query parameters
Target date in
YYYY-MM-DD format (e.g., 2024-06-02). Returns 400 if omitted or unparseable.Responses
| Status | Description |
|---|---|
| 200 | Prediction object for the requested date. |
| 400 | fecha parameter is missing or not a valid date. |
| 404 | No prediction found for the specified date. |
Example request
Example response
GET /api/predicciones/:id
Returns a single prediction document fetched directly from MongoDB by its ObjectId. This endpoint bypasses the file-based data sources. Authentication: None — public.Path parameters
MongoDB ObjectId of the prediction document.
Responses
| Status | Description |
|---|---|
| 200 | Prediction document with fecha serialized to YYYY-MM-DD. |
| 404 | No prediction with that ObjectId exists in MongoDB. |
Example request
Example response
Admin write endpoints
The following endpoints are restricted to users with theadmin role. They operate directly on the MongoDB prediccion collection and do not interact with the file-based data sources.
POST /api/predicciones
Creates a new prediction document in MongoDB. Authentication: Required —admin only.
Request body fields: fecha (required), precioestimado (required), preciominimo (required), preciomaximo (required), tendencia (optional, default estable), confianza (optional, 0–100).
Response: 201 with the created prediction document.
PUT /api/predicciones/:id
Updates an existing prediction by ObjectId. Authentication: Required —admin only.
Response: 200 with the updated prediction document. 404 if not found.
DELETE /api/predicciones/:id
Permanently deletes a prediction by ObjectId. Authentication: Required —admin only.
Response: 200 with { "message": "Prediccion eliminada correctamente" }. 404 if not found.