CoinPaprika PHP SDK
The official PHP client library for the CoinPaprika API provides convenient access to cryptocurrency market data. It uses Guzzle for HTTP requests and the JMS/Serializer for handling API responses.Installation
Install the CoinPaprika PHP SDK via Composer:Requirements
- PHP >= 7.2.5
- Composer for dependency management
guzzlehttp/guzzle
,jms/serializer
,symfony/yaml
,doctrine/cache
Quick Start
Basic Usage
The following example shows how to initialize the client and fetch global market statistics.Pro API with API Key
To access Pro API endpoints, provide your API key directly in the constructor.Get your API key at coinpaprika.com/api
Common Use Cases
Listing All Coins
This client does not have a method to fetch a single coin by its ID. Instead, you can fetch the full list of all coins and then find the one you need.Getting Ticker Data
You can fetch a list of all tickers or get a specific ticker by a coin’s ID.Search
The client provides a search endpoint that can look for currencies, exchanges, ICOs, people, and tags.Error Handling
The client throws specific exceptions for different types of errors. It’s best to wrap your API calls in atry-catch
block to handle these gracefully.
Available Methods
Global
getGlobalStats()
- Get global market overview.
Coins
getCoins()
- List all active coins.getTokenMeta(string $id)
- Get metadata for a specific token.
Tickers
getTickers()
- Get tickers for all coins.getTickerByCoinId(string $id)
- Get a specific ticker by coin ID.getHistoricalTickerByCoinId(string $id, string $start, string $interval)
- Get historical ticker data.
Exchanges
getExchanges()
- List all exchanges.getExchangeById(string $id)
- Get a specific exchange.getExchangeMarkets(string $id)
- Get markets for an exchange.
Tools
search(string $query, array $categories = null, int $limit = null)
- Search across coins, exchanges, etc.priceConverter(string $baseId, string $quoteId, float $amount)
- Convert between currencies.
Other
getIcos(array $parameters = [])
- Get a list of ICOs.setApiKey(string $apiKey)
- Set the API key after client initialization.getOHLCV(string $id, string $interval)
- Get the latest OHLCV data.