PHPackages                             cointokenhub/cmc-api-php - 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. cointokenhub/cmc-api-php

ActiveLibrary[API Development](/categories/api)

cointokenhub/cmc-api-php
========================

cmc-api-php is an API Wrapper for the coinmarketcap API

v1.1(8y ago)2141MITPHPPHP ^5.3.3 || ^7.0

Since Apr 22Pushed 8y ago1 watchersCompare

[ Source](https://github.com/cointokenhub/cmc-api-php)[ Packagist](https://packagist.org/packages/cointokenhub/cmc-api-php)[ RSS](/packages/cointokenhub-cmc-api-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

CoinMarketCap API Wrapper
=========================

[](#coinmarketcap-api-wrapper)

[![codecov](https://camo.githubusercontent.com/68a594195a2f8005b75836bbbf37c7d6dbb6d0f75046d6962b374570b298438d/68747470733a2f2f636f6465636f762e696f2f67682f636f696e746f6b656e6875622f636d632d6170692d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/cointokenhub/cmc-api-php) [![Build Status](https://camo.githubusercontent.com/e843c932859f013cec7a7b8391811c3946d64efc7c00a7bcee79eb274cefc970/68747470733a2f2f7472617669732d63692e6f72672f636f696e746f6b656e6875622f636d632d6170692d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cointokenhub/cmc-api-php)

This php package is a wrapper for the [coinmarketcap.com API](https://coinmarketcap.com/api/). It supports three endpoints:

- The ticker endpoint "/ticker", which returns all crypto currencies, and their vital statistics like price, volume, market cap and percentage changes
- The currency ticker endpoint "/ticker/", which returns all the data in the previous endpoint, except for only the specified coin.
- The global data endpoint "/global", which returns some stats like the total market cap, active currencies, active markets and so on.

Install
-------

[](#install)

```
composer require cointokenhub/cmc-api-php

```

Usage
-----

[](#usage)

### In a PHP app:

[](#in-a-php-app)

```
use GuzzleHttp\Client;
use CoinTokenHub\CoinMarketCapApi\CoinMarketCap;

$httpClient = new Client();
$cmcApi = new CoinMarketCap($httpClient);

$api->ticker('AUD', false, 5);
$api->currencyTicker($coin);
$api->globalData();
```

### In Laravel:

[](#in-laravel)

Add a route to `routes/web.php` that looks like below:

```
Route::get('coin/{coin}', 'CoinController@coin');
Route::get('ticker', 'CoinController@ticker');
Route::get('global_data', 'CoinController@globalData');
```

Controller looks like below:

```
