Skip to main content
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.
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 a try-catch block to handle these gracefully.

Available Methods

Global

Coins

Tickers

Exchanges

Tools

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.

FAQs

Pass the API key to the client constructor: new \Coinpaprika\Client(null, null, ‘YOUR_API_KEY’) for Pro features.
Look up IDs using the Coverage Checker; e.g., btc-bitcoin.
Use getHistoricalTickerByCoinId(id,id, start, $interval) with Pro access; for OHLCV see the REST endpoint.
Catch RateLimitExceededException or Guzzle client errors and retry with backoff.

Examples Repository

For more detailed examples, please see the official repository.

License

This library is available under the MIT license. See the LICENSE file for more info.