pangzlab/coingecko-api

v0.2.2 2022-12-16 01:08 UTC

This package is auto-updated.

Last update: 2024-04-25 09:29:32 UTC


README

chat on Discord follow on witter

68747470733a2f2f6c68332e676f6f676c6575736572636f6e74656e742e636f6d2f666966652f41506735454f593368314d473549336e7932643358394e49544e39474e7579783875506c457535305736476859772d437343505937685f38444e316c39755977384a37596a6d556c397044687555687636797268356776396a454e6f6157516350656251344e63737765544174734642326568575761394554725357434c6f525445566178323747734b474b5642366c4c594e4e313737364d7974707630526c4e5867736e412d316550333059516f7075643263716630594f5475646f2d6865616747346f6965424b424772324134436849725135743055676c4e59706d7a38515f4635376b396d6471386872427a75446d795568644649343074465a74675f76554b495a54595f76643242494a6d476b5a5a336e754d4d795a624f4f4d686753544d787a6c70623364413233476432796d4247664e6f62515a4f613468424f70645f58786962466f7835454f514f64395870536268645074304549417a584562347156734d4a345f4e4d57374f45646b304a51416a614173467a5a7656594c2d754b46752d767a575346675f4752577465446b55555968763630563148327a726d416644644e31306c4535593961694d6279632d363258537a614374474277536d6d6650386943644d505f52734a7175767157484a5445484b57366d4943384258624d71447538696554735571633876655242664852676e316941316c557977414255454c7941414e4d43715a34353076366e44594f436952584656654968392d4f334739507a476759753756306f374d534442684c2d3359306b454e79637349717a766e50534251583338424f4b67503737696e386158553975427a5332373543446f654356616c6f4e777832705a4f58566d4c466b37795f79424841726d3356443763746677505f4e7a4f6b4338347a4e636e3251567963676d426473586c554c6a5f512d504f5832575f4c4d37543454784c516b6f416e354234537642696b544e2d4c655f476532576b516b4963413755335f6a38475579775253595872386d373878655a4f445769397a4a4546556663387a59742d31395059637278305946536976774f714f7870496d2d49456d367834767961706a422d37582d6c6a786332547a6557714f5368586b796c35674b4b304576642d3055366854564e5f6d4c5f755057416c76574c73334c434b7539495a35625644456d4a567442737045687864726a51516a4e71757230316734564d793359795f4b684e69656e74755f414a6d376e644e41654151416f4b6667695574514e727459333036363438736c7252644b444f74356e544c57694855577658635571683675354b79544931594e426e65485179576b32457868784955465041693251556e7a6575323149424b556f656c65394244474b456f4f7a346456334a31716769302d3743316b767657746f78786e4c357a2d394c53777441455731766177356945793379684163624e396e724b744543304f3735653358485232655874344e4b784246376467645758396c535f6c6c736c497376773372467839564f4c6663434d37314854434f3374637a6c66386162784867315236546c4b574f47667161594f426471495271505046317361674c5a766265373575496a52626e437742615274566c345a317337513330495f384a6571326f4a52436e59516367626a7058527670436c4566686c4a54373679626f3968543261475f514645303153777074595132412d62746e776f396a696d48306863347649515852315f704d464851613632726432685369546c6135716f393557715451576f567462573535684e3268374c54463449426d314554596f38314b46704d3148547a5952374c5a514f514d73325f4261556143514265744f6d49575a4b684c57525a43385f58334f5653526f6b546a36787558746f7477634862586c6e363631495458732d317943786467576d70494c39326d506a4d6c6c6a4d55415f6b514a727530735f6c6d2d444571645a6146716d756a3466644e71476a5a75454e312d4651675652642d636f5348504b64344632525932646a7541544e42745155356e497757676d2d7475584d36594858334b7a6c694f7031676c517a5555526b4b56615571332d6c78676668593449785242676d4872773d77313836322d68393638

68747470733a2f2f70616e677a2d6c61622e6769746875622e696f2f636f75706f6e732f636f696e6765636b6f2d636770616e677a323430322d636f75706f6e2e706e67 68747470733a2f2f70616e677a2d6c61622e6769746875622e696f2f636f75706f6e732f636770616e677a323430322d636f75706f6e2d75736167652e706e67

coingecko-api

Coingecko API client for PHP


A simple, intuitive and composable API Client for the CoinGecko REST API Service.

API Version Support

  • ✔️ API v3
  • ✔️ Community Endpoint
  • ✔️ Pro Endpoint

Requirements

  • ✔️ php: 8.x
  • ✔️ guzzlehttp/guzzle: ^7.5

Installation

The best and the easiest way to use this library is thru composer. You can also download the source directly and require it to your project.

Just take note of the requirements.

[ Composer ]

composer see packagist.org

composer require pangzlab/coingecko-api

OR

[ Direct Download ]

📥 Get it from the release




Library

[ Classes ]

This library provides 2 main classes which you can use depending on the type of endpoints you are accessing.

CoinGeckoUrlBuilder CoinGeckoApiClient



📦 CoinGeckoApiClient

This is the main class that allows building the API endpoints and sending the request.

This is always required.

<?php

use PangzLab\CoinGecko\Client\CoinGeckoApiClient;

$client = new CoinGeckoApiClient();


📦 CoinGeckoUrlBuilder

CoinGecko API endpoints require a URL query which is a set of key value pairs encoded in the URL. This class enables to dynamically create them with ease without worrying the position or the casing of the keys.

Although by design can be achieved by using the CoinGeckoApiClient class alone, using the CoinGeckoUrlBuilder gives you a finer control over the parameters you set and more flexibility in managing the endpoints you're building.

This class is optional depending on the endpoint you need.

<?php

use PangzLab\CoinGecko\Client\CoinGeckoUrlBuilder;

$query = new CoinGeckoUrlBuilder();


Usage

Accessing the API endpoints are fairly straightforward. If not for convenience, you don't really need a set of manuals to start using this library. You can just go directly to the CoinGecko REST API Official Documenation, find the endpoint you need and start building your request.

Let's use some examples.

🔹 Endpoint request "without"🚫 URL query

🌐 endpoint: /ping

<?php

use PangzLab\CoinGecko\Client\CoinGeckoApiClient;

$client = new CoinGeckoApiClient();

try {

    $response = $client->set()->ping()->send();
    print_r($response);
    // do something here..

} catch (Exception $e) {
    print($e->getMessage());
}

🔹 Endpoint request "with"✔️ URL query

🌐 endpoint: /coins/categoreis

<?php

use PangzLab\CoinGecko\Client\CoinGeckoApiClient;
use PangzLab\CoinGecko\Client\CoinGeckoApiClient;

$q = new CoinGeckoUrlBuilder();
$client = new CoinGeckoApiClient();

try {

    $response = $apiClient->set()
        ->coins()
        ->categories()
        ->send($q->withOrder("name_desc"));
    print_r($response);
    // do something here ...

} catch (Exception $e) {
    print($e->getMessage());
}

🔹 Endpoint request with path parameter(id)

🌐 endpoint: /exchanges/{id}/volume_chart

<?php

use PangzLab\CoinGecko\Client\CoinGeckoApiClient;
use PangzLab\CoinGecko\Client\CoinGeckoUrlBuilder;

$q = new CoinGeckoUrlBuilder();
$client = new CoinGeckoApiClient();

try {

    $response = $apiClient->set()
        ->exchanges("safe_trade")
        ->volumeChart()
        ->send($q->withDays(1));
    print_r($response);
    // do something here ...

} catch (Exception $e) {
    print($e->getMessage());
}

🔹 Endpoint request with path parameter(id) and URL Query

🌐 endpoint: /coins/{id}

<?php

use PangzLab\CoinGecko\Client\CoinGeckoApiClient;
use PangzLab\CoinGecko\Client\CoinGeckoUrlBuilder;

$q = new CoinGeckoUrlBuilder();
$client = new CoinGeckoApiClient();

try {

    $response = $apiClient->set()
        ->coins("verus-coin")
        ->send(
            $q->withLocalization("false")
            ->withDeveloperData("true")
            ->withSparkline("true")
            ->withCommunityData("true")
            ->withMarketData("true")
            ->withTickers("true")
        );
    print_r($response);
    // do something here ...

} catch (Exception $e) {
    print($e->getMessage());
}

Features


Set Method

  • Before forming the endpoint, always start calling the set() method to make a clean object before building a request.

Parameter Positioning

  • The parameter position is not important. It can be set anywhere as long as it is required by the endpoint.

Send Methods ( Community vs Pro )

  • There are 2 methods provided to send a request. The send() and the sendPro()

  • send ⇨ used to send a request to Community API endpoints.

  • sendPro ⇨ used to send a request to the exclusive Pro API endpoints. This method requires the x_cg_pro_api_key parameter key encoded in the URL for the request to be accepted.

  • Both optionally accepts instance of CoinGeckoUrlBuilder() class.

  • Aside from the x_cg_pro_api_key parameter key, there is no major difference between these 2 methods. Both are used the same way.

CoinGeckoUrlBuilder() Method Call with Prefix

  • Method name for building a query string using CoinGeckoUrlBuilder() always have a prefix with.

  • (i.e. withId() for id, withVsCurrency() for vs_currency)



Bonus Quirks

There are some benefits of using this CoinGecko client libray.

Aside from it's not required to learn any methods to use and the parameter positioning of each methods, there are other features which might not be essential but are available and ready to be used to provide manageability and flexibility to your coding.

1. Use of reset() instead of set()

⚠️ Calling set() is always the preferred way but you can also build request using the reset() method to cleanup resource. Just make sure to separate the call to send() method to avoid ParseError.

<?php

use PangzLab\CoinGecko\Client\CoinGeckoApiClient;
use PangzLab\CoinGecko\Client\CoinGeckoUrlBuilder;

$q = new CoinGeckoUrlBuilder();
$client = new CoinGeckoApiClient();

try {

    //No set() method and no send() call
    $apiClient = $apiClient->coins("verus-coin");
    //Separate the call to send
    $response = $apiClient->send(
        $q->withLocalization("false")
        ->withDeveloperData("true")
        ->withSparkline("true")
        ->withCommunityData("true")
        ->withMarketData("true")
        ->withTickers("true")
    );
    print_r($response);

    //Call reset() method to form another request
    $apiClient->reset();
    $apiClient = $apiClient->exchanges("safe_trade")
        ->volumeChart();
    $response = $apiClient->send($q->withDays(1));

    //Call reset() for the next calls
    $apiClient->reset();

    print_r($response);

} catch (Exception $e) {
    print($e->getMessage());
}

2. Case-insensitive method names


Endpoint name and URL parameter key name are case-insensitive. This means calling ping(), PING() and Ping() are treated the same thing. Additionally you can also use underscore(_) as a separator for names like VS_CURRENCY or vs_Currency. They will be handled properly.


<?php

use PangzLab\CoinGecko\Client\CoinGeckoApiClient;
use PangzLab\CoinGecko\Client\CoinGeckoUrlBuilder;

$q = new CoinGeckoUrlBuilder();
$client = new CoinGeckoApiClient();

try {
    
    //All caps
    $response = $apiClient->set()
        ->PING()
        ->send();
    print_r($response);

    //All lowercase
    $response = $apiClient->set()
        ->ping()
        ->send();
    print_r($response);

    //UC First
    $response = $apiClient->set()
        ->Ping()
        ->send();
    print_r($response);

    //With underscore - only underscore is allowed
    $response = $apiClient->set()
        ->_PING_()
        ->send();
    print_r($response);

    //With insensitive parameter case
    $response = $apiClient
        ->coins("verus-coin")
        ->send(
            $q->with_LOCALIZATION("false")
            ->withDeveloperData_("true")
            ->withSparkline("true")
            ->withCommunity_DATA("true")
            ->with_Market_Data("true")
            ->withTiCKers("true")
        );
    print_r($response);

} catch (Exception $e) {
    print($e->getMessage());
}

3. Request reusability

<?php

use PangzLab\CoinGecko\Client\CoinGeckoApiClient;
use PangzLab\CoinGecko\Client\CoinGeckoUrlBuilder;

$q = new CoinGeckoUrlBuilder();
$client = new CoinGeckoApiClient();

try {

    $request = $apiClient->set()->ping();

    for($x = 0; $x <= 10; $x++) {
        $response = $request->send();
        sleep(3);
        print_r($response);
    }
    
} catch (Exception $e) {
    print($e->getMessage());
}

API Usage

📋Endpoint List

  1. ping
  2. simple
  3. coins
  4. contract
  5. coins
  6. asset_platforms
  7. categories
  8. exchanges
  9. indexes
  10. derivatives
  11. exchanges
  12. nfts (beta)
  13. exchange_rates
  14. search
  15. trending
  16. global
  17. companies (beta)

🌐 ping


1. 📋 endpoint : /ping

Check API server status

[ method ] :
ping()

💡 sample usage

$result = $apiClient->set()->ping()->send();

🌐 simple


1. 📋 endpoint : /simple/price

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

[ method ] :
simple()->price()

🔑 URL Keys : 7
✔️ withIds('string')❗️
✔️ withVsCurrencies('string')❗️
✔️ withIncludeMarketCap('string')
✔️ withInclude24hrVol('string')
✔️ withInclude24hrChange('string')
✔️ withIncludeLastUpdatedAt('string')
✔️ withPrecision('string')

url parameters
  1. ids ➞ string (required)

    ◽️ id of coins, comma-separated if querying more than 1 coinrefers to coins/list

  2. vs_currencies ➞ string (required)

    ◽️ vs_currency of coins, comma-separated if querying more than 1 vs_currencyrefers to simple/supported_vs_currencies

  3. include_market_cap ➞ string

    ◽️ true/false to include market_cap, default: false

  4. include_24hr_vol ➞ string

    ◽️ true/false to include 24hr_vol, default: false

  5. include_24hr_change ➞ string

    ◽️ true/false to include 24hr_change, default: false

  6. include_last_updated_at ➞ string

    ◽️ true/false to include last_updated_at of price, default: false

  7. precision ➞ string

    ◽️ full or any value between 0 - 18 to specify decimal place for currency price value, default: 2


💡 sample usage

$result = $apiClient->set()->simple()->price()
        ->send(
            $q->withIds('string')
                ->withVsCurrencies('string')
                ->withIncludeMarketCap('string')
                ->withInclude24hrVol('string')
                ->withInclude24hrChange('string')
                ->withIncludeLastUpdatedAt('string')
                ->withPrecision('string')
        );


2. 📋 endpoint : /simple/token_price/{id}

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

endpoint parameters
  1. id

    ➞ The id of the platform issuing tokens (See asset_platforms endpoint for list of options)

[ method ] :
simple()->tokenPrice('{id}')

🔑 URL Keys : 7
✔️ withContractAddresses('string')❗️
✔️ withVsCurrencies('string')❗️
✔️ withIncludeMarketCap('string')
✔️ withInclude24hrVol('string')
✔️ withInclude24hrChange('string')
✔️ withIncludeLastUpdatedAt('string')
✔️ withPrecision('string')

url parameters
  1. contract_addresses ➞ string (required)

    ◽️ The contract address of tokens, comma separated

  2. vs_currencies ➞ string (required)

    ◽️ vs_currency of coins, comma-separated if querying more than 1 vs_currency*refers to simple/supported_vs_currencies

  3. include_market_cap ➞ string

    ◽️ true/false to include market_cap, default: false

  4. include_24hr_vol ➞ string

    ◽️ true/false to include 24hr_vol, default: false

  5. include_24hr_change ➞ string

    ◽️ true/false to include 24hr_change, default: false

  6. include_last_updated_at ➞ string

    ◽️ true/false to include last_updated_at of price, default: false

  7. precision ➞ string

    ◽️ full or any Integer to specify decimal place for currency price value, default: 2


💡 sample usage

$result = $apiClient->set()->simple()->tokenPrice('{id}')
        ->send(
            $q->withContractAddresses('string')
                ->withVsCurrencies('string')
                ->withIncludeMarketCap('string')
                ->withInclude24hrVol('string')
                ->withInclude24hrChange('string')
                ->withIncludeLastUpdatedAt('string')
                ->withPrecision('string')
        );


3. 📋 endpoint : /simple/supported_vs_currencies

Get list of supported_vs_currencies.

[ method ] :
simple()->supportedVsCurrencies()

💡 sample usage

$result = $apiClient->set()->simple()->supportedVsCurrencies()->send();

🌐 coins


1. 📋 endpoint : /coins/list

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

[ method ] :
coins()->list()

🔑 URL Keys : 1
✔️ withIncludePlatform('boolean')

url parameters
  1. include_platform ➞ boolean

    ◽️ flag to include platform contract addresses (eg. 0x.... for Ethereum based tokens). valid values: true, false


💡 sample usage

$result = $apiClient->set()->coins()->list()
        ->send(
            $q->withIncludePlatform('boolean')
        );


2. 📋 endpoint : /coins/markets

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

[ method ] :
coins()->markets()

🔑 URL Keys : 8
✔️ withVsCurrency('string')❗️
✔️ withIds('string')
✔️ withCategory('string')
✔️ withOrder('string')
✔️ withPerPage('integer')
✔️ withPage('integer')
✔️ withSparkline('boolean')
✔️ withPriceChangePercentage('string')

url parameters
  1. vs_currency ➞ string (required)

    ◽️ The target currency of market data (usd, eur, jpy, etc.)

  2. ids ➞ string

    ◽️ The ids of the coin, comma separated crytocurrency symbols (base). refers to /coins/list.

  3. category ➞ string

    ◽️ filter by coin category. Refer to /coin/categories/list

  4. order ➞ string

    ◽️ valid values: market_cap_desc, gecko_desc, gecko_asc, market_cap_asc, market_cap_desc, volume_asc, volume_desc, id_asc, id_descsort results by field.

  5. per_page ➞ integer

    ◽️ valid values: 1..250 Total results per page

  6. page ➞ integer

    ◽️ Page through results

  7. sparkline ➞ boolean

    ◽️ Include sparkline 7 days data (eg. true, false)

  8. price_change_percentage ➞ string

    ◽️ Include price change percentage in 1h, 24h, 7d, 14d, 30d, 200d, 1y (eg. '1h,24h,7d' comma-separated, invalid values will be discarded)


💡 sample usage

$result = $apiClient->set()->coins()->markets()
        ->send(
            $q->withVsCurrency('string')
                ->withIds('string')
                ->withCategory('string')
                ->withOrder('string')
                ->withPerPage('integer')
                ->withPage('integer')
                ->withSparkline('boolean')
                ->withPriceChangePercentage('string')
        );


3. 📋 endpoint : /coins/{id}

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

endpoint parameters
  1. id

    ➞ pass the coin id (can be obtained from /coins) eg. bitcoin

[ method ] :
coins('{id}')

🔑 URL Keys : 6
✔️ withLocalization('string')
✔️ withTickers('boolean')
✔️ withMarketData('boolean')
✔️ withCommunityData('boolean')
✔️ withDeveloperData('boolean')
✔️ withSparkline('boolean')

url parameters
  1. localization ➞ string

    ◽️ Include all localized languages in response (true/false) [default: true]

  2. tickers ➞ boolean

    ◽️ Include tickers data (true/false) [default: true]

  3. market_data ➞ boolean

    ◽️ Include market_data (true/false) [default: true]

  4. community_data ➞ boolean

    ◽️ Include community_data data (true/false) [default: true]

  5. developer_data ➞ boolean

    ◽️ Include developer_data data (true/false) [default: true]

  6. sparkline ➞ boolean

    ◽️ Include sparkline 7 days data (eg. true, false) [default: false]


💡 sample usage

$result = $apiClient->set()->coins('{id}')
        ->send(
            $q->withLocalization('string')
                ->withTickers('boolean')
                ->withMarketData('boolean')
                ->withCommunityData('boolean')
                ->withDeveloperData('boolean')
                ->withSparkline('boolean')
        );


4. 📋 endpoint : /coins/{id}/tickers

Get coin tickers (paginated to 100 items)

endpoint parameters
  1. id

    ➞ pass the coin id (can be obtained from /coins/list) eg. bitcoin

[ method ] :
coins('{id}')->tickers()

🔑 URL Keys : 5
✔️ withExchangeIds('string')
✔️ withIncludeExchangeLogo('string')
✔️ withPage('integer')
✔️ withOrder('string')
✔️ withDepth('string')

url parameters
  1. exchange_ids ➞ string

    ◽️ filter results by exchange_ids (ref: v3/exchanges/list)

  2. include_exchange_logo ➞ string

    ◽️ flag to show exchange_logo

  3. page ➞ integer

    ◽️ Page through results

  4. order ➞ string

    ◽️ valid values: trust_score_desc (default), trust_score_asc and volume_desc

  5. depth ➞ string

    ◽️ flag to show 2% orderbook depth. valid values: true, false


💡 sample usage

$result = $apiClient->set()->coins('{id}')->tickers()
        ->send(
            $q->withExchangeIds('string')
                ->withIncludeExchangeLogo('string')
                ->withPage('integer')
                ->withOrder('string')
                ->withDepth('string')
        );


5. 📋 endpoint : /coins/{id}/history

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

endpoint parameters
  1. id

    ➞ pass the coin id (can be obtained from /coins) eg. bitcoin

[ method ] :
coins('{id}')->history()

🔑 URL Keys : 2
✔️ withDate('string')❗️
✔️ withLocalization('string')

url parameters
  1. date ➞ string (required)

    ◽️ The date of data snapshot in dd-mm-yyyy eg. 30-12-2017

  2. localization ➞ string

    ◽️ Set to false to exclude localized languages in response


💡 sample usage

$result = $apiClient->set()->coins('{id}')->history()
        ->send(
            $q->withDate('string')
                ->withLocalization('string')
        );


6. 📋 endpoint : /coins/{id}/market_chart

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

endpoint parameters
  1. id

    ➞ pass the coin id (can be obtained from /coins) eg. bitcoin

[ method ] :
coins('{id}')->marketChart()

🔑 URL Keys : 3
✔️ withVsCurrency('string')❗️
✔️ withDays('string')❗️
✔️ withInterval('string')

url parameters
  1. vs_currency ➞ string (required)

    ◽️ The target currency of market data (usd, eur, jpy, etc.)

  2. days ➞ string (required)

    ◽️ Data up to number of days ago (eg. 1,14,30,max)

  3. interval ➞ string

    ◽️ Data interval. Possible value: daily


💡 sample usage

$result = $apiClient->set()->coins('{id}')->marketChart()
        ->send(
            $q->withVsCurrency('string')
                ->withDays('string')
                ->withInterval('string')
        );


7. 📋 endpoint : /coins/{id}/market_chart/range

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

endpoint parameters
  1. id

    ➞ pass the coin id (can be obtained from /coins) eg. bitcoin

[ method ] :
coins('{id}')->marketChart()->range()

🔑 URL Keys : 3
✔️ withVsCurrency('string')❗️
✔️ withFrom('string')❗️
✔️ withTo('string')❗️

url parameters
  1. vs_currency ➞ string (required)

    ◽️ The target currency of market data (usd, eur, jpy, etc.)

  2. from ➞ string (required)

    ◽️ From date in UNIX Timestamp (eg. 1392577232)

  3. to ➞ string (required)

    ◽️ To date in UNIX Timestamp (eg. 1422577232)


💡 sample usage

$result = $apiClient->set()->coins('{id}')->marketChart()->range()
        ->send(
            $q->withVsCurrency('string')
                ->withFrom('string')
                ->withTo('string')
        );

🌐 contract


1. 📋 endpoint : /coins/{id}/contract/{contract_address}

Get coin info from contract address

endpoint parameters
  1. id

    ➞ Asset platform (See asset_platforms endpoint for list of options)

  2. contract_address

    ➞ Token's contract address

[ method ] :
coins('{id}')->contract('{contract_address}')

💡 sample usage

$result = $apiClient->set()->coins('{id}')->contract('{contract_address}')->send();


2. 📋 endpoint : /coins/{id}/contract/{contract_address}/market_chart/

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

endpoint parameters
  1. id

    ➞ The id of the platform issuing tokens (See asset_platforms endpoint for list of options)

  2. contract_address

    ➞ Token's contract address

[ method ] :
coins('{id}')->contract('{contract_address}')->marketChart()

🔑 URL Keys : 2
✔️ withVsCurrency('string')❗️
✔️ withDays('string')❗️

url parameters
  1. vs_currency ➞ string (required)

    ◽️ The target currency of market data (usd, eur, jpy, etc.)

  2. days ➞ string (required)

    ◽️ Data up to number of days ago (eg. 1,14,30,max)


💡 sample usage

$result = $apiClient->set()->coins('{id}')->contract('{contract_address}')->marketChart()
        ->send(
            $q->withVsCurrency('string')
                ->withDays('string')
        );


3. 📋 endpoint : /coins/{id}/contract/{contract_address}/market_chart/range

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

endpoint parameters
  1. id

    ➞ The id of the platform issuing tokens (See asset_platforms endpoint for list of options)

  2. contract_address

    ➞ Token's contract address

[ method ] :
coins('{id}')->contract('{contract_address}')->marketChart()->range()

🔑 URL Keys : 3
✔️ withVsCurrency('string')❗️
✔️ withFrom('string')❗️
✔️ withTo('string')❗️

url parameters
  1. vs_currency ➞ string (required)

    ◽️ The target currency of market data (usd, eur, jpy, etc.)

  2. from ➞ string (required)

    ◽️ From date in UNIX Timestamp (eg. 1392577232)

  3. to ➞ string (required)

    ◽️ To date in UNIX Timestamp (eg. 1422577232)


💡 sample usage

$result = $apiClient->set()->coins('{id}')->contract('{contract_address}')->marketChart()->range()
        ->send(
            $q->withVsCurrency('string')
                ->withFrom('string')
                ->withTo('string')
        );

🌐 coins


1. 📋 endpoint : /coins/{id}/ohlc

Get coin's OHLC

endpoint parameters
  1. id

    ➞ pass the coin id (can be obtained from /coins/list) eg. bitcoin

[ method ] :
coins('{id}')->ohlc()

🔑 URL Keys : 2
✔️ withVsCurrency('string')❗️
✔️ withDays('string')❗️

url parameters
  1. vs_currency ➞ string (required)

    ◽️ The target currency of market data (usd, eur, jpy, etc.)

  2. days ➞ string (required)

    ◽️ Data up to number of days ago (1/7/14/30/90/180/365/max)


💡 sample usage

$result = $apiClient->set()->coins('{id}')->ohlc()
        ->send(
            $q->withVsCurrency('string')
                ->withDays('string')
        );

🌐 asset_platforms


1. 📋 endpoint : /asset_platforms

List all asset platforms (Blockchain networks)

[ method ] :
assetPlatforms()

🔑 URL Keys : 1
✔️ withFilter('string')

url parameters
  1. filter ➞ string

    ◽️ apply relevant filters to results valid values: "nft" (asset_platform nft-support)


💡 sample usage

$result = $apiClient->set()->assetPlatforms()
        ->send(
            $q->withFilter('string')
        );

🌐 categories


1. 📋 endpoint : /coins/categories/list

List all categories

[ method ] :
coins()->categories()->list()

💡 sample usage

$result = $apiClient->set()->coins()->categories()->list()->send();


2. 📋 endpoint : /coins/categories

List all categories with market data

[ method ] :
coins()->categories()

🔑 URL Keys : 1
✔️ withOrder('string')

url parameters
  1. order ➞ string

    ◽️ valid values: market_cap_desc (default), market_cap_asc, name_desc, name_asc, market_cap_change_24h_desc and market_cap_change_24h_asc


💡 sample usage

$result = $apiClient->set()->coins()->categories()
        ->send(
            $q->withOrder('string')
        );

🌐 exchanges


1. 📋 endpoint : /exchanges

List all exchanges (Active with trading volumes)

[ method ] :
exchanges()

🔑 URL Keys : 2
✔️ withPerPage('integer')
✔️ withPage('string')

url parameters
  1. per_page ➞ integer

    ◽️ Valid values: 1...250Total results per pageDefault value:: 100

  2. page ➞ string

    ◽️ page through results


💡 sample usage

$result = $apiClient->set()->exchanges()
        ->send(
            $q->withPerPage('integer')
                ->withPage('string')
        );


2. 📋 endpoint : /exchanges/list

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

[ method ] :
exchanges()->list()

💡 sample usage

$result = $apiClient->set()->exchanges()->list()->send();


3. 📋 endpoint : /exchanges/{id}

Get exchange volume in BTC and top 100 tickers only

endpoint parameters
  1. id

    ➞ pass the exchange id (can be obtained from /exchanges/list) eg. binance

[ method ] :
exchanges('{id}')

💡 sample usage

$result = $apiClient->set()->exchanges('{id}')->send();


4. 📋 endpoint : /exchanges/{id}/tickers

Get exchange tickers (paginated, 100 tickers per page)

endpoint parameters
  1. id

    ➞ pass the exchange id (can be obtained from /exchanges/list) eg. binance

[ method ] :
exchanges('{id}')->tickers()

🔑 URL Keys : 5
✔️ withCoinIds('string')
✔️ withIncludeExchangeLogo('string')
✔️ withPage('integer')
✔️ withDepth('string')
✔️ withOrder('string')

url parameters
  1. coin_ids ➞ string

    ◽️ filter tickers by coin_ids (ref: v3/coins/list)

  2. include_exchange_logo ➞ string

    ◽️ flag to show exchange_logo

  3. page ➞ integer

    ◽️ Page through results

  4. depth ➞ string

    ◽️ flag to show 2% orderbook depth i.e., cost_to_move_up_usd and cost_to_move_down_usd

  5. order ➞ string

    ◽️ valid values: trust_score_desc (default), trust_score_asc and volume_desc


💡 sample usage

$result = $apiClient->set()->exchanges('{id}')->tickers()
        ->send(
            $q->withCoinIds('string')
                ->withIncludeExchangeLogo('string')
                ->withPage('integer')
                ->withDepth('string')
                ->withOrder('string')
        );

🌐 indexes


1. 📋 endpoint : /indexes

List all market indexes

[ method ] :
indexes()

🔑 URL Keys : 2
✔️ withPerPage('integer')
✔️ withPage('integer')

url parameters
  1. per_page ➞ integer

    ◽️ Total results per page

  2. page ➞ integer

    ◽️ Page through results


💡 sample usage

$result = $apiClient->set()->indexes()
        ->send(
            $q->withPerPage('integer')
                ->withPage('integer')
        );


2. 📋 endpoint : /indexes/{market_id}/{id}

get market index by market id and index id

endpoint parameters
  1. market_id

    ➞ pass the market id (can be obtained from /exchanges/list)

  2. id

    ➞ pass the index id (can be obtained from /indexes/list)

[ method ] :
indexes('{market_id}','{id}')

💡 sample usage

$result = $apiClient->set()->indexes('{market_id}','{id}')->send();


3. 📋 endpoint : /indexes/list

list market indexes id and name

[ method ] :
indexes()->list()

💡 sample usage

$result = $apiClient->set()->indexes()->list()->send();

🌐 derivatives


1. 📋 endpoint : /derivatives

List all derivative tickers

[ method ] :
derivatives()

🔑 URL Keys : 1
✔️ withIncludeTickers('string')

url parameters
  1. include_tickers ➞ string

    ◽️ ['all', 'unexpired'] - expired to show unexpired tickers, all to list all tickers, defaults to unexpired


💡 sample usage

$result = $apiClient->set()->derivatives()
        ->send(
            $q->withIncludeTickers('string')
        );


2. 📋 endpoint : /derivatives/exchanges

List all derivative exchanges

[ method ] :
derivatives()->exchanges()

🔑 URL Keys : 3
✔️ withOrder('string')
✔️ withPerPage('integer')
✔️ withPage('integer')

url parameters
  1. order ➞ string

    ◽️ order results using following params name_asc,name_desc,open_interest_btc_asc,open_interest_btc_desc,trade_volume_24h_btc_asc,trade_volume_24h_btc_desc

  2. per_page ➞ integer

    ◽️ Total results per page

  3. page ➞ integer

    ◽️ Page through results


💡 sample usage

$result = $apiClient->set()->derivatives()->exchanges()
        ->send(
            $q->withOrder('string')
                ->withPerPage('integer')
                ->withPage('integer')
        );


3. 📋 endpoint : /derivatives/exchanges/{id}

show derivative exchange data

endpoint parameters
  1. id

    ➞ pass the exchange id (can be obtained from derivatives/exchanges/list) eg. bitmex

[ method ] :
derivatives()->exchanges('{id}')

🔑 URL Keys : 1
✔️ withIncludeTickers('string')

url parameters
  1. include_tickers ➞ string

    ◽️ ['all', 'unexpired'] - expired to show unexpired tickers, all to list all tickers, leave blank to omit tickers data in response


💡 sample usage

$result = $apiClient->set()->derivatives()->exchanges('{id}')
        ->send(
            $q->withIncludeTickers('string')
        );


4. 📋 endpoint : /derivatives/exchanges/list

List all derivative exchanges name and identifier

[ method ] :
derivatives()->exchanges()->list()

💡 sample usage

$result = $apiClient->set()->derivatives()->exchanges()->list()->send();

🌐 exchanges


1. 📋 endpoint : /exchanges/{id}/volume_chart

Get volume_chart data for a given exchange

endpoint parameters
  1. id

    ➞ pass the exchange id (can be obtained from /exchanges/list) eg. binance

[ method ] :
exchanges('{id}')->volumeChart()

🔑 URL Keys : 1
✔️ withDays('integer')❗️

url parameters
  1. days ➞ integer (required)

    ◽️ Data up to number of days ago (eg. 1,14,30)


💡 sample usage

$result = $apiClient->set()->exchanges('{id}')->volumeChart()
        ->send(
            $q->withDays('integer')
        );

🌐 nfts (beta)


1. 📋 endpoint : /nfts/list

List all supported NFT ids, paginated by 100 items per page, paginated to 100 items

[ method ] :
nfts()->list()

🔑 URL Keys : 4
✔️ withOrder('string')
✔️ withAssetPlatformId('string')
✔️ withPerPage('integer')
✔️ withPage('integer')

url parameters
  1. order ➞ string

    ◽️ valid values: h24_volume_native_asc, h24_volume_native_desc, floor_price_native_asc, floor_price_native_desc, market_cap_native_asc, market_cap_native_desc, market_cap_usd_asc, market_cap_usd_desc

  2. asset_platform_id ➞ string

    ◽️ The id of the platform issuing tokens (See asset_platforms endpoint for list of options)

  3. per_page ➞ integer

    ◽️ Total results per page

  4. page ➞ integer

    ◽️ Page through results


💡 sample usage

$result = $apiClient->set()->nfts()->list()
        ->send(
            $q->withOrder('string')
                ->withAssetPlatformId('string')
                ->withPerPage('integer')
                ->withPage('integer')
        );


2. 📋 endpoint : /nfts/{id}

Get current data (name, price_floor, volume_24h ...) for an NFT collection

endpoint parameters
  1. id

    ➞ id of nft collection (can be obtained from /nfts/list)

[ method ] :
nfts('{id}')

💡 sample usage

$result = $apiClient->set()->nfts('{id}')->send();


3. 📋 endpoint : /nfts/{asset_platform_id}/contract/{contract_address}

Get current data (name, price_floor, volume_24h ...) for an NFT collection

endpoint parameters
  1. asset_platform_id

    ➞ The id of the platform issuing tokens (See asset_platforms endpoint for list of options, use filter=nft param)

  2. contract_address

    ➞ The contract_address of the nft collection (/nfts/list for list of nft collection with metadata)

[ method ] :
nfts('{asset_platform_id}')->contract('{contract_address}')

💡 sample usage

$result = $apiClient->set()->nfts('{asset_platform_id}')->contract('{contract_address}')->send();

🌐 exchange_rates


1. 📋 endpoint : /exchange_rates

Get BTC-to-Currency exchange rates

[ method ] :
exchangeRates()

💡 sample usage

$result = $apiClient->set()->exchangeRates()->send();

🌐 search


1. 📋 endpoint : /search

Search for coins, categories and markets on CoinGecko

[ method ] :
search()

🔑 URL Keys : 1
✔️ withQuery('string')❗️

url parameters
  1. query ➞ string (required)

    ◽️ Search string


💡 sample usage

$result = $apiClient->set()->search()
        ->send(
            $q->withQuery('string')
        );

🌐 trending


1. 📋 endpoint : /search/trending

Get trending search coins (Top-7) on CoinGecko in the last 24 hours

[ method ] :
search()->trending()

💡 sample usage

$result = $apiClient->set()->search()->trending()->send();

🌐 global


1. 📋 endpoint : /global

Get cryptocurrency global data

[ method ] :
global()

💡 sample usage

$result = $apiClient->set()->global()->send();


2. 📋 endpoint : /global/decentralized_finance_defi

Get cryptocurrency global decentralized finance(defi) data

[ method ] :
global()->decentralizedFinanceDefi()

💡 sample usage

$result = $apiClient->set()->global()->decentralizedFinanceDefi()->send();

🌐 companies (beta)


1. 📋 endpoint : /companies/public_treasury/{coin_id}

Get public companies data

endpoint parameters
  1. coin_id

    ➞ bitcoin or ethereum

[ method ] :
companies()->publicTreasury('{coin_id}')

💡 sample usage

$result = $apiClient->set()->companies()->publicTreasury('{coin_id}')->send();