This library provides convenient way to use coinpaprika.com API in PHP.
Coinpaprika delivers full market data to the world of crypto: coin prices, volumes, market caps, ATHs, return rates and more.
- PHP >= 8.0
- (optional) PHPUnit to run tests.
Via Composer:
$ composer require coinpaprika/coinpaprika-api-php-client<?php
// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';
$client = new \Coinpaprika\Client();
$coins = $client->getCoins();From $client object, you can access all the endpoints.
For deserialization process it is advised to initiate the $client with $cacheDir argument.
<?php
// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';
$client = new \Coinpaprika\Client(cacheDir: 'my/cache/directory');
$coins = $client->getTickers();Pass the API key as the first constructor argument (or use setApiKey() after construction). The client will automatically route requests to api-pro.coinpaprika.com.
<?php
// This file is generated by Composer
require_once __DIR__ . '/vendor/autoload.php';
$client = new \Coinpaprika\Client('PROVIDED_API_KEY');
$coins = $client->getCoins();$client = new \Coinpaprika\Client();$client->getGlobalStats(); // Global market overview
$client->getCoins(); // List all coins
$client->getTokenMeta('btc-bitcoin'); // Coin details
$client->getTickers(); // All tickers
$client->getTickerByCoinId('btc-bitcoin'); // Ticker for coin
$client->getHistoricalTickerByCoinId('btc-bitcoin', '2024-01-01', '24h'); // Historical$client->getOHLCV('btc-bitcoin', '24h'); // Latest OHLCV
$client->getTodayOHLCV('btc-bitcoin'); // Today's OHLCV
$client->getHistoricalOHLCV('btc-bitcoin', '2024-01-01'); // Historical OHLCV$client->getExchanges(); // ExchangeDetail[]
$client->getExchangeById('binance'); // ExchangeDetail
$client->getExchangeMarkets('binance'); // array (raw)$client->getCoinTwitter('btc-bitcoin'); // array (raw)
$client->getCoinEvents('btc-bitcoin'); // array (raw)
$client->getCoinExchanges('btc-bitcoin'); // array (raw)
$client->getCoinMarkets('btc-bitcoin'); // Market[]
$client->getCoinsMappings(); // array (raw, Pro)$client->getPlatforms(); // List platforms
$client->getContracts('eth-ethereum'); // Contracts on Ethereum
$client->getTickerByContract('eth-ethereum', '0xdac1...'); // Ticker by contract
$client->getHistoricalByContract('eth-ethereum', '0xdac1...', ['start' => '2024-01-01']);$client->search('bitcoin'); // Search
$client->priceConverter(['base_currency_id' => 'btc-bitcoin', 'quote_currency_id' => 'usd-us-dollars', 'amount' => 1]);
$client->getPersonById('vitalik-buterin'); // array (raw)
$client->getTags(); // array (raw)
$client->getTagById('blockchain-service'); // array (raw)
$client->getKeyInfo(); // KeyInfo (requires API key)
$client->getCoinsMappings(); // CoinMapping[] (Business+)
$client->getChangelogIds(); // ChangelogEntry[] (paid plans)
$client->getIcos(); // Ico[]Endpoints come in two flavors:
- Typed — returned as JMS-deserialized model classes under
Coinpaprika\Model\*. Covers the bulk of the surface:GlobalStats,Ticker,HistoricalTicker,Coin,CoinMeta,OHLCV,Ico,Search,Market,ExchangeDetail,KeyInfo,CoinMapping,ChangelogEntry. - Raw
array— auxiliary endpoints whose shape is easier to work with as a plain decoded-JSON blob (Twitter timelines, events, tags, contracts, price converter, etc.). The Coinpaprika API reference is the source of truth for those shapes.
Check out the ./examples directory. For a quick end-to-end sanity run against the live API:
php examples/smokeTest.php # free API
API_KEY=xxx php examples/smokeTest.php # Pro APILoad/latency profiling:
STRESS_ITERATIONS=100 php examples/stressTest.php # ~10s at default 100ms delay
STRESS_ITERATIONS=500 STRESS_DELAY_MS=50 php examples/stressTest.php
API_KEY=xxx STRESS_ITERATIONS=1000 php examples/stressTest.php # Pro bypasses rate limitsSee CHANGELOG.md for release notes and migration guidance.
CoinpaprikaAPI is available under the MIT license. See the LICENSE file for more info.

