PHPackages                             jalallinux/price-feed - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. jalallinux/price-feed

ActiveLibrary[API Development](/categories/api)

jalallinux/price-feed
=====================

Price Feed is a Laravel package for fetching real-time prices of multiple asset types — including cryptocurrencies, fiat currencies, gold, silver, and metal derivatives — through a unified driver-based architecture.

03[3 PRs](https://github.com/jalallinux/price-feed/pulls)PHPCI passing

Since Oct 13Pushed 1mo agoCompare

[ Source](https://github.com/jalallinux/price-feed)[ Packagist](https://packagist.org/packages/jalallinux/price-feed)[ RSS](/packages/jalallinux-price-feed/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

Price Feed
==========

[](#price-feed)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6a29bc250098c165ad5f202fd9371a171c6e86cfee349d1b2a84bb22c7724b9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a616c616c6c696e75782f70726963652d666565642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jalallinux/price-feed)[![Total Downloads](https://camo.githubusercontent.com/dfe4babc7a90af475d24dc50d5c4f8ebc881cbad04f807093689e4bc066e5dff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a616c616c6c696e75782f70726963652d666565642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jalallinux/price-feed)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A comprehensive Laravel package for fetching real-time prices of multiple asset types including cryptocurrencies, fiat currencies, gold, silver, and precious metal derivatives through a unified driver-based architecture.

Features
--------

[](#features)

- **Multi-Asset Support**: Cryptocurrencies, fiat currencies, and precious metals
- **Driver-Based Architecture**: Easily extensible with multiple data providers
- **Built-in Caching**: Configurable caching with TTL support
- **Type Safety**: Full PHP 8.4+ type safety with enums and DTOs
- **Laravel Integration**: Seamless Laravel service provider and facade integration
- **Multiple Providers**: Support for TGJU, Brsapi, and TGN APIs
- **Comprehensive Testing**: Full test coverage with Pest PHP

Supported Assets
----------------

[](#supported-assets)

### Cryptocurrencies

[](#cryptocurrencies)

- Bitcoin (BTC), Ethereum (ETH), Tether (USDT)
- Binance Coin (BNB), XRP, Cardano (ADA)
- Dogecoin (DOGE), Solana (SOL), TRON (TRX)
- Polkadot (DOT), Polygon (MATIC), Litecoin (LTC)
- Shiba Inu (SHIB), Avalanche (AVAX)
- Uniswap (UNI), Chainlink (LINK)

### Fiat Currencies

[](#fiat-currencies)

- USD, EUR, GBP, JPY, CNY
- AUD, CAD, CHF, IRR, AED, TRY

### Precious Metals

[](#precious-metals)

- Gold (various purities and forms)
- Silver (999, 925, ounce)
- Platinum, Palladium
- Iranian Gold Coins (various denominations)

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require jalallinux/price-feed
```

The package will automatically register its service provider and facade.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="JalalLinuX\PriceFeed\PriceFeedServiceProvider" --tag="config"
```

Configure your environment variables:

```
# Default driver
PRICE_FEED_DRIVER=tgju

# TGJU Configuration
TGJU_CACHE_ENABLED=true
TGJU_CACHE_TTL=120

# Brsapi Configuration
BRSAPI_API_KEY=your_api_key_here
BRSAPI_CACHE_ENABLED=true
BRSAPI_CACHE_TTL=120

# TGN Configuration
TGN_USERNAME=your_username
TGN_API_KEY=your_api_key
TGN_CACHE_ENABLED=true
TGN_CACHE_TTL=120
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use JalalLinuX\PriceFeed\Facades\PriceFeed;
use JalalLinuX\PriceFeed\Enums\Currency;

// Get price for a single currency
$btcPrice = PriceFeed::price(Currency::BTC);

// Get prices for multiple currencies
$prices = PriceFeed::prices([
    Currency::BTC,
    Currency::ETH,
    Currency::USD
]);

// Get all supported currencies
$supportedCurrencies = PriceFeed::supportedCurrencies();

// Get available drivers
$drivers = PriceFeed::availableDrivers();
```

### Using Specific Drivers

[](#using-specific-drivers)

```
// Use a specific driver
$btcPrice = PriceFeed::driver('brsapi')->getPrice(Currency::BTC);

// Get prices from specific driver
$prices = PriceFeed::driver('tgn')->getPrices([
    Currency::USD,
    Currency::EUR
]);
```

### Working with Price Data

[](#working-with-price-data)

```
$priceData = PriceFeed::price(Currency::BTC);

echo $priceData->currency->value; // BTC
echo $priceData->price; // 125000000.0
echo $priceData->unit->value; // IRR
echo $priceData->symbol; // BTC
echo $priceData->change24h; // 2500000.0
echo $priceData->changePercentage24h; // 2.04
echo $priceData->high24h; // 130000000.0
echo $priceData->low24h; // 120000000.0
echo $priceData->timestamp->format('Y-m-d H:i:s'); // 2024-01-15 14:30:00
```

### Cache Management

[](#cache-management)

```
// Clear cache for specific currency
PriceFeed::clearCache(Currency::BTC);

// Clear cache for specific driver
PriceFeed::clearCache(null, 'tgju');

// Clear all cache
PriceFeed::clearCache();
```

Available Drivers
-----------------

[](#available-drivers)

### TGJU Driver

[](#tgju-driver)

- **Provider**: TGJU (Tehran Gold and Jewelry Union)
- **Coverage**: Fiat currencies, precious metals
- **Unit**: Iranian Rial (IRR)
- **Authentication**: None required
- **API**: Free public API

### Brsapi Driver

[](#brsapi-driver)

- **Provider**: Brsapi.ir
- **Coverage**: Cryptocurrencies, fiat currencies, precious metals
- **Unit**: Iranian Toman (IRT)
- **Authentication**: API key required
- **API**: Commercial API

### TGN Driver

[](#tgn-driver)

- **Provider**: TGN Services
- **Coverage**: Fiat currencies, precious metals, coins
- **Unit**: Iranian Toman (IRT)
- **Authentication**: Username and API key required
- **API**: Commercial API

Configuration Reference
-----------------------

[](#configuration-reference)

The package configuration is located in `config/price-feed.php`:

```
return [
    'default' => env('PRICE_FEED_DRIVER', 'tgju'),

    'drivers' => [
        'tgju' => [
            'driver' => \JalalLinuX\PriceFeed\Drivers\TgjuDriver::class,
            'base_url' => 'https://call5.tgju.org',
            'unit' => \JalalLinuX\PriceFeed\Enums\CurrencyUnit::IRR,
            'cache_enabled' => true,
            'cache_ttl' => 120,
            'currencies' => [
                // Configured currencies
            ],
        ],
        // Other drivers...
    ],
];
```

Testing
-------

[](#testing)

Run the tests with:

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

Code Quality
------------

[](#code-quality)

Format code with Laravel Pint:

```
composer format
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [JalalLinuX](https://github.com/jalallinux)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Support
-------

[](#support)

If you find this package useful, please consider starring it on GitHub and sharing it with others!

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance60

Regular maintenance activity

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ddef4e15a6bda9c060f6e33ccfd0a268895bfb664936f9191a836de4d528d684?d=identicon)[jalallinux](/maintainers/jalallinux)

---

Top Contributors

[![jalallinux](https://avatars.githubusercontent.com/u/37062636?v=4)](https://github.com/jalallinux "jalallinux (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/jalallinux-price-feed/health.svg)

```
[![Health](https://phpackages.com/badges/jalallinux-price-feed/health.svg)](https://phpackages.com/packages/jalallinux-price-feed)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
