Download the PHP package tetthys/crypto-price without Composer
On this page you can find all versions of the php package tetthys/crypto-price. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tetthys/crypto-price
More information about tetthys/crypto-price
Files in tetthys/crypto-price
Package crypto-price
Short Description Ultra-light crypto price service (USD spot + converters) for PHP 8.3+.
License MIT
Informations about the package crypto-price
tetthys/crypto-price
Lightweight, framework-agnostic crypto price utility for PHP 8.3+.
Provides simple USD spot price access, crypto-to-USD conversion, and scale-aware math using BCMath.
📦 Installation
`
Requires PHP 8.3+ and the bcmath extension.
🚀 Quick Example
🧩 Core Concepts
CryptoPriceProviderInterface
Defines a source that returns USD spot price per crypto symbol.
Example:
getUsdPrice('BTC')→"98765.4321"getUsdPrice('ETH')→"3456.78"
CryptoPriceService
A high-level service that performs conversions and handles decimal precision per asset.
All math uses BCMath to ensure fixed-scale precision.
CryptoScale
A static mapping of default decimal scales per symbol:
| Symbol | Default scale |
|---|---|
| BTC | 8 |
| LTC | 8 |
| XMR | 12 |
| ETH | 8 |
| USDT | 6 |
Use CryptoScale::get('BTC') to retrieve the default scale.
CallableCryptoPriceProvider
A minimal provider that wraps a closure. Perfect for tests or static pricing environments.
⚙️ Integrating with Laravel
You can easily wire this package into Laravel using a small provider:
or register both in a custom CryptoPriceServiceProvider:
🧪 Testing with a Mock Provider
🪪 License
MIT © Tetthys Labs
All versions of crypto-price with dependencies
ext-bcmath Version *