Skip to content

CoinGecko PHP API client for coingecko.com (V3)

License

Notifications You must be signed in to change notification settings

chartaholic/coingecko-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP API client for coingecko.com

Build Status Scrutinizer Code Quality Test Coverage Maintainability License: MIT

image info

A simple API client, written with PHP for coingecko.com.

CoinGecko provides a fundamental analysis of the crypto market. In addition to tracking price, volume and market capitalization, CoinGecko tracks community growth, open-source code development, major events and on-chain metrics.

For additional information about API visit coingecko.com/api

CoinGecko API Terms of Service

Requirements

  • PHP >= 7.2
  • ext-json

Installation

The preferred way to install this extension is through composer.

Either run

$ composer require codenix-sv/coingecko-api

or add

"codenix-sv/coingecko-api": "^1.0"

Basic usage

Example

use Codenixsv\CoinGeckoApi\CoinGeckoClient;

$client = new CoinGeckoClient();
$data = $client->ping();

You can get last response (ResponseInterface::class) uses getLastResponse method:

use Codenixsv\CoinGeckoApi\CoinGeckoClient;

$client = new CoinGeckoClient();
$data = $client->derivatives()->getExchanges();
$response = $client->getLastResponse();
$headers = $response->getHeaders();

Available methods

Ping

Check API server status

$data = $client->ping();

Simple

Get the current price of any cryptocurrencies in any other supported currencies that you need.

$data = $client->simple()->getPrice('0x,bitcoin', 'usd,rub');

Get current price of tokens (using contract addresses) for a given platform in any other currency that you need.

$data = $client->simple()->getTokenPrice('ethereum','0xE41d2489571d322189246DaFA5ebDe1F4699F498', 'usd,rub');

Get list of supported_vs_currencies.

$data = $client->simple()->getSupportedVsCurrencies();

Coins

List all supported coins id, name and symbol (no pagination required)

$data = $client->coins()->getList();

List all supported coins price, market cap, volume, and market related data

$data = $result = $client->coins()->getMarkets('usd');

Get current data (name, price, market, ... including exchange tickers) for a coin

$result = $client->coins()->getCoin('bitcoin', ['tickers' => 'false', 'market_data' => 'false']);

Get coin tickers (paginated to 100 items)

$result = $client->coins()->getTickers('bitcoin');

Get historical data (name, price, market, stats) at a given date for a coin

$result = $client->coins()->getHistory('bitcoin', '30-12-2017');

Get historical market data include price, market cap, and 24h volume (granularity auto)

$result = $client->coins()->getMarketChart('bitcoin', 'usd', 'max');

Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)

$result = $client->coins()->getMarketChartRange('bitcoin', 'usd', '1392577232', '1422577232');

Get status updates for a given coin

$result = $client->coins()->getStatusUpdates('0x');

Contract

Get coin info from contract address

$data = $client->contract()->getContract('ethereum', '0xE41d2489571d322189246DaFA5ebDe1F4699F498');

Get historical market data include price, market cap, and 24h volume (granularity auto) from a contract address

$result = $client->contract()->getMarketChart('ethereum', '0xE41d2489571d322189246DaFA5ebDe1F4699F498', 'usd', '1');

Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto) from a contract address

$result = $result = $client->contract()->getMarketChartRange('ethereum', '0xE41d2489571d322189246DaFA5ebDe1F4699F498', 'usd', '11392577232', ' 1422577232');

Exchange [BETA]

List all exchanges

$data = $client->exchanges()->getExchanges();

List all supported markets id and name (no pagination required)

$data = $client->exchanges()->getList();

Get exchange volume in BTC and top 100 tickers only

$data = $client->exchanges()->getExchange('binance');

Get exchange tickers (paginated)

$data = $client->exchanges()->getTickers('binance', ['coin_ids' => '0x,bitcoin']);

Get status updates for a given exchange (beta)

$data = $client->exchanges()->getStatusUpdates('binance');

Get volume_chart data for a given exchange (beta)

$data = $client->exchanges()->getVolumeChart('binance', '1');

Finance [BETA]

List all finance platforms

$data = $client->finance()->getPlatforms();

List all finance products

$data = $client->finance()->getProducts();

Indexes [BETA]

List all market indexes

$data = $client->indexes()->getIndexes();

Get market index by id

$data = $client->indexes()->getIndex('BAT');

List market indexes id and name

$data = $client->indexes()->getList();

Derivatives [BETA]

List all derivative tickers

$data = $client->derivatives()->getDerivatives();

List all derivative exchanges

$data = $client->derivatives()->getExchanges();

Show derivative exchange data

$data = $client->derivatives()->getExchange('binance_futures');

List all derivative exchanges name and identifier

$data = $client->derivatives()->getExchangeList();

Status updates [BETA]

List all status_updates with data (description, category, created_at, user, user_title and pin)

$data = $client->statusUpdates()->getStatusUpdates();

Events [BETA]

Get events, paginated by 100

$data = $client->events()->getEvents();

Get list of event countries

$data = $client->events()->getCountries();

Get list of events types

$data = $client->events()->getTypes();

Exchange rates [BETA]

Get BTC-to-Currency exchange rates

$data = $client->exchangeRates()->getExchangeRates();

Global [BETA]

Get cryptocurrency global data

$data = $client->globals()->getGlobal();

License

codenix-sv/coingecko-api is released under the MIT License. See the bundled LICENSE for details.

About

CoinGecko PHP API client for coingecko.com (V3)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%