Kaufland Articles Endpoints¶
Base path: /api/v1/multi + router prefix /kaufland/articles → full base: /api/v1/multi/kaufland/articles
Summary: Endpoints to sync Kaufland units into the repricer DB, calculate Kaufland-specific min/max prices and expected profit using configured margin rules, and push minimum/listing prices back to Kaufland (and Plenty). Includes cron control for scheduled runs.
Auth: Bearer JWT required for all endpoints.
Notes: Heavy operations (sync, recalc, export) run in background tasks; they broadcast progress via WebSocket (notify_clients) and use the KauflandService which enforces Kaufland's rate limits (default 111 req/sec). Price values in Kaufland API are cents (integers) — the service converts to/from euros when persisting DB records.
Endpoints¶
- POST /cron/start — Start or update Kaufland repricer cron job
- Body/Query:
schedule(cron expression, default0 8 * * *) - Response:
CronStartResponsewithmessageandschedule -
Behavior: registers a
kaufland_repricer_cronjob viaCronJobManagerthat runs the canonical workflow (sync → recalc → export). -
POST /cron/stop — Stop Kaufland cron job
-
Response:
CronStopResponse -
GET /cron/status — Get cron job status
-
Response:
CronStatusResponsewithstatus,expression,last_run_at,next_run_at,active. -
POST /recalculate — Recalculate pricing for all articles (background)
- Response:
200{ "message": "Recalculation started in background" } -
Runs:
recalculate_articles(db, sku=None)in background. -
POST /recalculate/{sku} — Recalculate pricing for specific SKU (background)
- Path param:
sku(string) -
Response:
200{ "message": "Recalculation started in background", "sku": "<SKU>" } -
POST /send_minimum_prices/{sku} — Push calculated min/listing prices to Kaufland (background)
- Path param:
sku(useallto export all eligible items) - Query/body: optional
storefrontfilter (e.g.,de) - Behavior: For each eligible article, calls
KauflandService.patch_unit_data()withminimum_priceandlisting_price(values converted to cents). On success the Kaufland details are updated in DB; on failure anerror_messageis persisted. -
Also attempts to update Plenty (
Plenty_Manager.change_price_by_sku) for thekauflandchannel when Plenty credentials are active. -
POST /sync/{sku} — Sync units from Kaufland into DB (background)
- Path param:
sku(useallto sync all units) - Query:
storefront(defaultde) — selects storefront to import. - Behavior: Fetches all units via
KauflandService.get_all_units(), enriches category data viaget_categories_tree()andassign_categories_to_units(), fetches buybox info per product, and upsertsKauflandDetailsrecord for each SKU. Removes DB Kaufland details that no longer exist in Kaufland.
Core workflows (implementation notes)¶
- Cron workflow (
kaufland_repricer_runner→cron_job_wrapper): sync_articles_from_api(storefront, db)— retrieves current units and upserts Kaufland details.recalculate_articles(db, storefront)— calculatesminimum_price,maximum_price,expected_profit, and assignsmargin_rule_id.-
send_min_prices_to_kaufland(db, storefront)— pushesminimum_price/listing_priceto Kaufland and updates Plenty. -
Recalculation logic (
recalculate_articles): - Reads
brutto_buy_price(gross buy price) and converts it to net using the shop VAT (vat_pct/ 100). - Uses
variable_fee_pctandfixed_fee(from KauflandKauflandDetails) pluspackage_costto compute floor prices. - Two helper calculations:
- Price from margin pct: solves for P in margin equation using net buy price and fees.
- Price from absolute profit: solves for P so that absolute profit >= configured
min_min_profit.
minimum_price= max(price_for_min_margin, price_for_min_profit) rounded to 2 decimals.maximum_price= floor(calculated_max_price) + 0.90 (ensures.90endings).expected_profitcomputed from current listing price (if present).-
Persists
minimum_price,maximum_price,margin_rule_id,expected_profit, and updatesstatustoUPDATE_NEEDEDwhen values changed. -
Export logic (
send_min_prices_to_kaufland): - Validates required fields:
brutto_buy_price,minimum_price,maximum_price, andid_unit. - Calls
KauflandService.patch_unit_data(id_unit, storefront, update_data)whereupdate_datacontains cents integers forminimum_priceandlisting_price. - On success, clears
error_messageand sets DB status toACTIVEif previously notUPDATE_NEEDED. - If Plenty is configured, the flow attempts
Plenty_Manager.change_price_by_sku(sku, new_price, channel='kaufland')to keep Plenty in sync.
Errors & telemetry¶
- Background tasks log summary counts (
created,updated,deleted,successful,failed) and emit WebSockettask_statusmessages withsource=kaufland. - On partial failures (missing fields, API errors) the endpoint persists
error_messageon theKauflandDetailsrecord so frontends can surface problems.
Examples¶
- Recalculate all SKUs (background):
curl -X POST "http://localhost:8000/api/v1/multi/kaufland/articles/recalculate" \
-H "Authorization: Bearer <TOKEN>"
- Recalculate single SKU:
curl -X POST "http://localhost:8000/api/v1/multi/kaufland/articles/recalculate/B07SKU123" \
-H "Authorization: Bearer <TOKEN>"
- Sync storefront
de(background):
curl -X POST "http://localhost:8000/api/v1/multi/kaufland/articles/sync/all?storefront=de" \
-H "Authorization: Bearer <TOKEN>"
- Push minimum/listing prices for all SKUs:
curl -X POST "http://localhost:8000/api/v1/multi/kaufland/articles/send_minimum_prices/all" \
-H "Authorization: Bearer <TOKEN>"
Links¶
- Endpoint implementation:
backend/service_multi-repricer/app/api/v1/endpoints/kaufland_articles.py - Kaufland API wrapper:
backend/service_multi-repricer/app/services/kaufland/kaufland_service.py - Kaufland rate limiter:
backend/service_multi-repricer/app/services/kaufland/rate_limiter.py
Generated: reference for Kaufland article endpoints and workflows used by service_multi-repricer.
Kaufland Articles Endpoints¶
Router prefix: /kaufland/articles → full base: /api/v1/multi/kaufland/articles
Summary: Cron control, sync and recalc endpoints for Kaufland article flows. TODO: expand with detailed method list, parameters and examples.
Implementation: backend/service_multi-repricer/app/api/v1/endpoints/kaufland_articles.py
TODO: Populate detailed method table and examples.