2017 © Pedro Peláez
 

library cmc-api-php

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

image

cointokenhub/cmc-api-php

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

  • Wednesday, April 25, 2018
  • by ckailash
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 50 % Grown

The README.md

CoinMarketCap API Wrapper

codecov Build Status, (*1)

This php package is a wrapper for the coinmarketcap.com API. It supports three endpoints:, (*2)

  • 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

composer require cointokenhub/cmc-api-php

Usage

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:

Add a route to routes/web.php that looks like below:, (*3)

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

Controller looks like below:, (*4)

<?php

namespace App\Http\Controllers;

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

class CoinController extends Controller
{
    private $httpClient;

    public function __construct(Client $httpClient) {
        $this->httpClient = $httpClient;
    }

    public function coin($coin) {
        $api = new CoinMarketCap($this->httpClient);
        return json_encode($api->currencyTicker($coin));
    }

    public function ticker() {
        $api = new CoinMarketCap($this->httpClient);
        return json_encode($api->ticker('AUD', false, 5));
    }

    public function globalData() {
        $api = new CoinMarketCap($this->httpClient);
        return json_encode($api->globalData());
    }
}

Configuring for Laravel

Laravel 5.5 and higher

You don't need to change or add any config as this package uses Package Auto Discovery., (*5)

Laravel 5.4 and lower

After installing, register the CoinTokenHub\CoinMarketCapApi\CoinMarketCapServiceProvider service provider in your config/app.php file., (*6)

'providers' => [
    // Other service providers...

    CoinTokenHub\CoinMarketCapApi\CoinMarketCapServiceProvider::class,
],

Also add the facade to your aliases array in the config/app.php file in order to easily access this wrapper using the CoinMarketCap alias, (*7)

'CoinMarketCap' => CoinTokenHub\CoinMarketCapApi\CoinMarketCapFacade::class,

The Versions

25/04 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kailash Chandrasekaran

24/04 2018

v1.1

1.1.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kailash Chandrasekaran

22/04 2018

v1.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kailash Chandrasekaran