-
Notifications
You must be signed in to change notification settings - Fork 26
[Price Compare] Step 12: Price check API endpoint #83
Copy link
Copy link
Open
Description
Step 12 — Price Check API Endpoint
Add a REST API endpoint to cijene-api that accepts a product code (sifra) and chain name, and returns current prices across Dubrovnik stores.
Endpoint:
GET /api/v1/price-check?code={sifra}&chain={chain_code}
Parameters:
| Param | Type | Required | Description |
|---|---|---|---|
code |
string | yes | Product code (Metro sifra, Konzum code, etc.) |
chain |
string | no | Chain filter: metro, konzum, tommy, etc. If omitted, search all chains |
city |
string | no | City filter (default: Dubrovnik) |
Response:
{
"query": { "code": "224155", "chain": null, "city": "Dubrovnik" },
"product": {
"name": "180G ARO TEK.JOGURT 2,8%",
"code": "224155",
"category": "Mliječni proizvodi"
},
"prices": [
{
"chain": "metro",
"store": "Metro Dubrovnik",
"price": 0.30,
"unit_price": 1.67,
"unit": "€/kg",
"date": "2026-03-01",
"quantity": "180 G"
}
],
"cheapest": {
"chain": "metro",
"unit_price": 1.67,
"savings_vs_most_expensive": "33.2%"
}
}Implementation:
- Add to
service/routers/v1.py(or newservice/routers/price_check.py) - Reuse existing
dbconnection fromsettings.get_db() - SQL: lookup
chain_products.code→ joinprices→ filter by store city/chain - Requires auth (existing
RequireAuthdependency) - Also support fuzzy name search:
GET /api/v1/price-check?name=jogurt&chain=metro
Use cases:
- Atrium ERP integration — when creating purchase order, check real-time prices
- Manual spot-check from terminal
- Future: Atrium UI "check alternatives" button
Files: service/routers/v1.py or service/routers/price_check.py
Priority: P2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels