spatie/spatie-price-api
Fetch pricing information from Spatie’s spatie.be API, used internally on Spatie product promotional sites. Includes a simple method to retrieve a price for a purchasable item. Open source but not intended for third-party use.
PriceFetcherInterface) to allow switching APIs later.interface PriceFetcherInterface {
public function getPrice(string $sku): float;
}
class SpatiePriceFetcher implements PriceFetcherInterface {
use SpatiePriceApi;
// ...
}
$price = Cache::remember("price_{$sku}", now()->addHours(1), function () {
return SpatiePriceApi::getPrice($sku);
});
try {
return SpatiePriceApi::getPrice($sku);
} catch (Exception $e) {
return Price::where('sku', $sku)->value('fallback_price') ?? 0;
}
Product::withPrice()).cached_price, last_fetched_at).| Failure Scenario | Impact | Mitigation Strategy |
|---|---|---|
| Spatie API downtime | Prices unavailable | Local cache + fallback defaults |
| API rate limiting | Throttled requests | Implement retry logic + caching |
| Price data discrepancies | Inconsistent pricing | Audit logs + manual override workflow |
How can I help you explore Laravel packages today?