The Price History API provides a time-series audit log of every price that has been published or modified by a buyer on the platform. History records are immutable snapshots — they are never edited or deleted by the application. Two endpoints are available: a global listing with optional filters, and a buyer-scoped listing. Base URL:Documentation 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.
/api/historial-precios
Authentication: Required for all endpoints. Include a valid Authorization: Bearer <token> header on every request.
How history records are created
A newHistorialPrecio document is written automatically in two scenarios:
POST /api/precios— a snapshot of the newly created price is saved immediately after the price document is inserted.PUT /api/precios/:id— a snapshot of the updated price is saved immediately after the price document is modified.
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /api/historial-precios | Required | List all price history records |
| GET | /api/historial-precios/comprador/:compradorId | Required | List history records for a specific buyer |
GET /api/historial-precios
Returns up to the 100 most recent price history records across all buyers, sorted bycreatedAt descending. Supports optional query-parameter filtering.
Authentication: Required.
Query parameters
Filter results to a specific buyer by their MongoDB ObjectId. When provided, only records where
comprador matches this ID are returned.Filter results by coffee type. When provided, only records matching this type are returned.Allowed values:
pergamino_seco, especial, organico, verde, pasilla, cacao, limonResponse
An array of up to 100 history objects, sorted newest first. Each object contains the full buyer sub-document populated withnombreempresa and direccion.
Response fields
MongoDB ObjectId of the history record.
Populated buyer reference. Contains
_id, nombreempresa, and direccion.Price per load (or per kg, for kg-unit types) recorded in this snapshot.
Derived price per kilogram at the time the snapshot was taken. For carga-based types, this is
preciocarga / 125. For kg-based types (pasilla, cacao, limon), this equals preciocarga.Coffee or product type recorded in this snapshot. One of
pergamino_seco, especial, organico, verde, pasilla, cacao, limon.Timestamp when this history record was created. Because records are never modified,
createdAt is also the effective timestamp of the price change event.Example request
Example request with filters
Example response
GET /api/historial-precios/comprador/:compradorId
Returns all history records for a single buyer, sorted bycreatedAt descending. Unlike the global endpoint, this route has no 100-record cap — it returns the full history for the buyer.
Authentication: Required.
Path parameters
MongoDB ObjectId of the buyer whose price history you want to retrieve.
Response
An array of history objects for the specified buyer, sorted newest first. Each record’scomprador field is populated with nombreempresa only (no direccion).
Response fields
Same schema as the global endpoint. See Response fields above.Responses
| Status | Description |
|---|---|
| 200 | Array of history records. Empty array [] if the buyer has no history. |
| 500 | Internal server error. |