The Prices API is the core market-data layer of CoffePrice. It exposes the current buying prices that approved coffee buyers (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.
comprador) publish for each coffee type. Producers use the public GET endpoints to compare offers across the market in real time. Authenticated buyers and admins use POST, PUT, and DELETE to manage their own price listings. Every write operation automatically logs a history entry, re-evaluates active producer price alerts, and dispatches email notifications to all active producers on the platform.
Base URL: /api/precios
| Method | Path | Auth | Description |
|---|---|---|---|
| GET | /api/precios | None (public) | List all approved buyer prices |
| GET | /api/precios/comprador/:compradorId | None (public) | List all prices for a specific buyer |
| POST | /api/precios | comprador or admin | Publish a new price |
| PUT | /api/precios/:id | Owner comprador or admin | Update an existing price |
| DELETE | /api/precios/:id | Owner comprador or admin | Remove a price listing |
| GET | /api/precio-fnc | None (public) | Get the current scraped FNC reference price |
GET /api/precios
Returns all active price listings from approved buyers. Results are sorted bypreciocarga descending and deduplicated so that only the highest price per buyer appears (one listing per buyer).
Authentication: None — public, rate-limited.
Query parameters
Filter results to a single coffee or product type. Omit to return all types.Allowed values:
pergamino_seco, especial, organico, verde, pasilla, cacao, limonResponse fields
MongoDB ObjectId of the price document.
Partial buyer profile. Only fields safe for public display are included.
Coffee or product type. One of
pergamino_seco, especial, organico, verde, pasilla, cacao, limon.Buyer’s offered price per load (carga) or per kilogram, depending on
unidad.Derived price per kilogram. For carga-based types, calculated as
preciocarga / 125. For kg-based types (pasilla, cacao, limon), equals preciocarga.Unit of measure:
carga for pergamino_seco, especial, organico, and verde; kg for pasilla, cacao, and limon. Set automatically on save based on tipocafe.Timestamp when the price was first created.
Timestamp of the most recent update.
Example request
Example response
GET /api/precios/comprador/:compradorId
Returns all price listings published by a specific buyer. The buyer’s account must be in an approved state; otherwise the API responds with404.
Authentication: None — public.
Path parameters
MongoDB ObjectId of the buyer whose prices you want to retrieve.
Error responses
| Status | Condition |
|---|---|
| 404 | Buyer not found, or buyer is not yet approved by an admin. |
| 500 | Internal server error. |
Example request
Example response
POST /api/precios
Creates a new price listing for a buyer. The authenticated user must be the owner of thecomprador profile referenced in the request body, or an admin.
Authentication: Required — comprador or admin role.
After a successful save, the server:
- Writes a snapshot to the price history log (
HistorialPrecio). - Queries all active alerts whose
precioMinimois less than or equal to the newpreciocargaand sends email notifications to the alert owners. - Dispatches an email notification about the new listing to every active producer on the platform.
Duplicate prevention
If an identical combination ofcomprador, tipocafe, and preciocarga was already submitted within the last 60 seconds, the server skips the insert and returns the existing document with HTTP 200 instead of 201.
Request body
MongoDB ObjectId of the buyer (
comprador) profile to associate this price with. The authenticated user must own this profile, or be an admin.Offered price. Must be a finite number greater than
0. Represents price per carga for pergamino_seco, especial, organico, and verde; price per kg for pasilla, cacao, and limon.Type of coffee or agricultural product.Allowed values:
pergamino_seco, especial, organico, verde, pasilla, cacao, limonResponses
| Status | Description |
|---|---|
| 201 | Price created successfully. Returns the new price document. |
| 200 | Duplicate detected within the 60-second window. Returns the existing document. |
| 400 | Missing or invalid fields. |
| 403 | Authenticated user does not own the buyer profile, or the buyer is not approved. |
| 404 | Buyer not found. |
Example request
Example response
PUT /api/precios/:id
Updates an existing price listing. The authenticated user must be the owner of the buyer profile linked to the price, or anadmin.
Authentication: Required — owner comprador or admin role.
After saving, the server writes a new history snapshot and re-runs the alert and producer-notification pipeline, identical to POST /api/precios.
Path parameters
MongoDB ObjectId of the price document to update.
Request body
New price value. Must be a finite number greater than
0. Omit to leave unchanged.New coffee type. Must be one of the allowed enum values. Omit to leave unchanged.Allowed values:
pergamino_seco, especial, organico, verde, pasilla, cacao, limonResponses
| Status | Description |
|---|---|
| 200 | Price updated successfully. Returns the updated price document. |
| 400 | Invalid field value. |
| 403 | Authenticated user does not own the buyer profile, or the buyer is not approved. |
| 404 | Price or associated buyer not found. |
Example request
Example response
DELETE /api/precios/:id
Permanently removes a price listing. The authenticated user must be the owner of the buyer profile linked to the price, or anadmin.
Authentication: Required — owner comprador or admin role.
Path parameters
MongoDB ObjectId of the price document to delete.
Responses
| Status | Description |
|---|---|
| 200 | Price deleted successfully. |
| 403 | Authenticated user does not own the buyer profile, or the buyer is not approved. |
| 404 | Price or associated buyer not found. |
| 500 | Internal server error. |
Example request
Example response
GET /api/precio-fnc
Returns the current FNC (Federación Nacional de Cafeteros) reference price served from an in-memory cache. This price is scraped automatically by a background job and refreshed on a schedule. Authentication: None — public, rate-limited. If the cache is populated and fresh, the response is returned immediately. If the cache is stale, a background refresh is triggered in the background and the last known value is returned instantly. If the cache is empty and a refresh is already in progress, the server responds with HTTP202. If no price can be obtained at all, the server responds with HTTP 503.
Response fields
Current FNC reference price in Colombian pesos (COP).
null if unavailable.Source identifier for the scraped value.
null if unavailable.Human-readable timestamp of the last successful scrape, formatted in the
America/Bogota timezone. null if unavailable.Present on non-fresh responses.
false when a synchronous refresh just succeeded; true when the value is outdated or unavailable. Omitted on normal cached responses.Present on
202 and 503 responses. Human-readable status message explaining the current cache state, in Spanish.Responses
| Status | Condition |
|---|---|
| 200 | Cache is populated. Returns the current price. May include stale: false if a blocking refresh just completed. |
| 202 | Cache is empty and a refresh is already running. Returns precio: null with stale: false and a message. |
| 503 | No price is available and all refresh attempts failed. Returns precio: null with stale: true and a message. |