Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Spatie Price Api

Spatie Price Api Laravel Package

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.

View on GitHub
Deep Wiki
Context7

The price API used at promotional sites for our own products

Frequently asked questions about Spatie Price Api
How do I install spatie/spatie-price-api in my Laravel project?
Run `composer require spatie/spatie-price-api` in your project directory. The package integrates seamlessly with Laravel’s service container and requires no additional configuration unless you need custom caching or error handling.
What Laravel versions does this package support?
Check the package’s [Packagist page](https://packagist.org/packages/spatie/spatie-price-api) for the latest version’s requirements. As of now, it supports Laravel 8.x and 9.x, but always verify compatibility before installation.
Can I use this package for non-Spatie products or third-party pricing?
No, this package is explicitly designed for Spatie’s own promotional sites and products. While open source, it relies on Spatie’s internal API (spatie.be), which isn’t intended for third-party use or general pricing needs.
How do I fetch a price for a product using this package?
Use the `SpatiePriceApi::getPriceForPurchasable()` method, passing a purchasable object (e.g., an Eloquent model with a `sku` or identifier). The method returns the current price from Spatie’s API, which you can then display or process in your application.
Does this package support caching to reduce API calls?
Yes, leverage Laravel’s caching mechanisms (e.g., Redis, file cache) to store price responses. Wrap the API call in a cache layer like `Cache::remember()` to minimize external requests and improve performance under high traffic.
What happens if Spatie’s API is down or returns an error?
The package doesn’t include built-in fallback logic, so you’ll need to implement error handling (e.g., retry logic, cached fallback values, or default pricing) based on your application’s requirements. Consider using Laravel’s exception handling or a queue job for resilience.
Is there a way to test this package locally without hitting Spatie’s API?
Yes, mock the `SpatiePriceApi` facade or use Laravel’s HTTP client mocking to simulate API responses during testing. The package’s test suite also serves as a reference for testing edge cases like failed requests or invalid SKUs.
Can I integrate this with a microservices architecture?
This package assumes a monolithic Laravel setup where price data is fetched externally. In a microservices environment, you’d need to abstract the API call into a dedicated service (e.g., a price service) and handle caching or retries at that layer to avoid tight coupling.
Are there alternatives for fetching real-time pricing in Laravel?
For third-party pricing, consider packages like `spatie/laravel-shop` (for e-commerce) or `orchid/shop` (for Shopify/WooCommerce integrations). For custom APIs, use Laravel’s HTTP client (`Http::get()`) with caching, or build a self-hosted pricing service.
How do I handle rate limits or API costs if Spatie’s pricing changes?
Monitor Spatie’s API documentation for rate limits or usage tiers. Implement request throttling (e.g., `throttle` middleware) and budget alerts. If costs become prohibitive, evaluate migrating to a self-hosted solution or a different pricing API provider.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport