Otto Article History Endpoints¶
Location: backend/service_multi-repricer/app/api/v1/endpoints/otto_article_history.py
Purpose
Provide CRUD operations and maintenance utilities for ItemPricingHistory records captured for Otto marketplace articles. These records store historical my_price and sale_price snapshots per SKU and timestamp, used for auditing, trend analysis and debugging repricer behavior.
Primary models
- Request/response model:
ItemPricingHistory(schema) - Create model:
ItemPricingHistoryCreate(model) - Update model:
ItemPricingHistoryUpdate(model)
Endpoints
- POST
/— Add new history entry - Request:
ItemPricingHistoryCreateJSON -
Response:
ItemPricingHistory(201 Created) -
PUT
/{history_id}— Update history entry by id - Path:
history_id(int) - Request:
ItemPricingHistoryUpdate -
Response:
ItemPricingHistory(200) -
DELETE
/{history_id}— Delete history entry by id -
Response: 204 No Content
-
GET
/sku/{sku}— Get all history entries for a SKU -
Returns a list of
ItemPricingHistoryobjects sorted bytimestampdescending. -
GET
/sku/latest/{sku}— Get latest history entry for a SKU -
Returns a single
ItemPricingHistoryobject (200) ornullif not found. -
DELETE
/cleanup— Delete history entries older than 90 days - Response:
{ "message": "Cleaned up X old history entries...", "deleted_count": X } -
Default retention: 90 days (UTC cutoff)
-
DELETE
/cleanup-redundant— Remove redundant consecutive entries - Removes newer entries where
my_priceandsale_priceequal the immediately previous entry for the same SKU, keeping the oldest entry for a given price state. - Response:
{ "message": "Redundant history entries cleaned up", "deleted_count": X }
Examples
- Create history entry (curl)
curl -X POST "http://localhost:8000/api/v1/multi/otto-article-history/" \
-H "Content-Type: application/json" \
-d '{"sku": "SKU123", "my_price": 12.99, "sale_price": 9.99, "timestamp": "2026-05-22T12:00:00Z"}'
- Cleanup old entries (run periodically, e.g., daily)
curl -X DELETE "http://localhost:8000/api/v1/multi/otto-article-history/cleanup"
Operational notes
- Retention: default cleanup uses a 90-day cutoff; adjust schedule or logic if your retention policy differs.
- Performance:
cleanup_redundantexecutes a SQL window-function based delete which can be expensive on large tables — run during maintenance windows or in smaller batches if needed. - Indexes: ensure
item_pricing_historyhas indexes onskuandtimestampto make lookups and cleanup efficient.
Otto Article History Endpoints¶
Router prefix: /otto/history → full base: /api/v1/multi/otto/history
Summary: Pricing history retrieval and cleanup endpoints for Otto article history. TODO: expand with CRUD and retention endpoints.
Implementation: backend/service_multi-repricer/app/api/v1/endpoints/otto_article_history.py
TODO: Populate detailed method table and examples.