cURL
curl --request GET \ --url https://api.example.com/api/v1/products/{product_id}/price-history
{ "id": "<string>", "product_id": "<string>", "old_price": 123, "new_price": 123, "reason": "<string>", "created_at": "<string>" }
Retrieve complete price change history for a specific product
admin
gestor
consultor
curl -X GET https://api.example.com/api/v1/products/a1b2c3d4-e5f6-7890-abcd-ef1234567890/price-history \ -H "Authorization: Bearer YOUR_TOKEN"
[ { "id": "hist-001", "product_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "old_price": 4.99, "new_price": 5.49, "reason": "Seasonal price increase", "created_at": "2026-03-01T10:30:00Z" }, { "id": "hist-002", "product_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "old_price": 4.49, "new_price": 4.99, "reason": "Supplier cost adjustment", "created_at": "2026-02-15T14:20:00Z" }, { "id": "hist-003", "product_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "old_price": 3.99, "new_price": 4.49, "reason": "Initial price correction", "created_at": "2026-01-10T09:00:00Z" } ]
[]
async function fetchPriceHistory(productId) { const response = await fetch( `https://api.example.com/api/v1/products/${productId}/price-history`, { headers: { 'Authorization': `Bearer ${token}` } } ); const history = await response.json(); // Display in a chart or table history.forEach(entry => { console.log(`${entry.created_at}: ${entry.old_price} → ${entry.new_price}`); console.log(`Reason: ${entry.reason}`); }); }
import requests from datetime import datetime def get_price_stats(product_id, token): url = f"https://api.example.com/api/v1/products/{product_id}/price-history" headers = {"Authorization": f"Bearer {token}"} response = requests.get(url, headers=headers) history = response.json() if not history: return {"message": "No price history available"} prices = [entry["new_price"] for entry in history] return { "current_price": prices[0], "lowest_price": min(prices), "highest_price": max(prices), "average_price": sum(prices) / len(prices), "total_changes": len(history) }