A Laravel package for interacting with the CoinMarketCap API.
Laravel 11 requires PHP 8.1+ and Composer.
To install the latest version, run:
composer require kriosmane/coinmarketcap-apiFrom Laravel 11, service providers and facades are auto-discovered. However, if you need to register them manually, add the following to your config/app.php file:
'providers' => [
KriosMane\CoinMarketCap\Providers\CoinMarketCapServiceProvider::class,
],'aliases' => [
'CoinMarketCapApi' => KriosMane\CoinMarketCap\Facades\CoinMarketCap::class,
],Publish the configuration file using:
php artisan vendor:publish --provider="KriosMane\CoinMarketCap\Providers\CoinMarketCapServiceProvider"This will create a coinmarketcap.php file in your config directory.
Get your CoinMarketCap API Key from:
Then, add the key to your .env file:
CMC_API_KEY=your-api-key-hereYou can start using the API in your controllers or services:
use CoinMarketCap;
// Get latest cryptocurrency listings
$cryptos = CoinMarketCap::listCryptos();
// Get latest market quotes for a specific cryptocurrency
$quotes = CoinMarketCap::getQuotes(['symbol' => 'BTC,ETH']);Feel free to fork this repository and submit a pull request to enhance its functionality.
If you found this package helpful, consider buying me a coffee!
☕ Buy me a coffee
⭐ Star the repo, share it on Twitter, or post about it on HackerNews. Spread the word!
Thank you!
Krios Mane
Please see License File for more information.