forked from codenix-sv/coingecko-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbangs
374 lines (234 loc) · 10.6 KB
/
bangs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# PHP API client for coingecko.com
[![Build Status](https://travis-ci.com/codenix-sv/coingecko-api.svg?branch=master)](https://travis-ci.com/codenix-sv/coingecko-api)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/codenix-sv/coingecko-api/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/codenix-sv/coingecko-api/?branch=master)
[![Test Coverage](https://api.codeclimate.com/v1/badges/650015976f280641822a/test_coverage)](https://codeclimate.com/github/codenix-sv/coingecko-api/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/650015976f280641822a/maintainability)](https://codeclimate.com/github/codenix-sv/coingecko-api/maintainability)
[![License: MIT](https://img.shields.io/github/license/codenix-sv/coingecko-api)](https://github.com/codenix-sv/coingecko-api/blob/master/LICENSE)
![image info](./CoinGeckoLogo.png)
A simple API client, written with PHP for [coingecko.com](https://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](https://www.coingecko.com/api)
CoinGecko API [Terms of Service](https://www.coingecko.com/en/api_terms)
## Requirements
* PHP >= 7.2
* ext-json
## Installation
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```bash
$ composer require codenix-sv/coingecko-api
```
or add
```json
"codenix-sv/coingecko-api": "^1.0"
```
## Basic usage
### Example
```php
use Codenixsv\CoinGeckoApi\CoinGeckoClient;
$client = new CoinGeckoClient();
$data = $client->ping();
```
You can get last response (`ResponseInterface::class`) uses `getLastResponse` method:
```php
use Codenixsv\CoinGeckoApi\CoinGeckoClient;
$client = new CoinGeckoClient();
$data = $client->derivatives()->getExchanges();
$response = $client->getLastResponse();
$headers = $response->getHeaders();
```
## Available methods
### Ping
#### [ping](https://www.coingecko.com/api/documentations/v3#/ping/get_ping)
Check API server status
```php
$data = $client->ping();
```
### Simple
#### [getPrice](https://www.coingecko.com/api/documentations/v3#/simple/get_simple_price)
Get the current price of any cryptocurrencies in any other supported currencies that you need.
```php
$data = $client->simple()->getPrice('0x,bitcoin', 'usd,rub');
```
#### [getTokenPrice](https://www.coingecko.com/api/documentations/v3#/simple/get_simple_price)
Get current price of tokens (using contract addresses) for a given platform in any other currency that you need.
```php
$data = $client->simple()->getTokenPrice('ethereum','0xE41d2489571d322189246DaFA5ebDe1F4699F498', 'usd,rub');
```
#### [getSupportedVsCurrencies](https://www.coingecko.com/api/documentations/v3#/simple/get_simple_supported_vs_currencies)
Get list of supported_vs_currencies.
```php
$data = $client->simple()->getSupportedVsCurrencies();
```
### Coins
#### [getList](https://www.coingecko.com/api/documentations/v3#/coins/get_coins_list)
List all supported coins id, name and symbol (no pagination required)
```php
$data = $client->coins()->getList();
```
#### [getMarkets](https://www.coingecko.com/api/documentations/v3#/coins/get_coins_markets)
List all supported coins price, market cap, volume, and market related data
```php
$data = $result = $client->coins()->getMarkets('usd');
```
#### [getCoin](https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id_)
Get current data (name, price, market, ... including exchange tickers) for a coin
```php
$result = $client->coins()->getCoin('bitcoin', ['tickers' => 'false', 'market_data' => 'false']);
```
#### [getTickers](https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__tickers)
Get coin tickers (paginated to 100 items)
```php
$result = $client->coins()->getTickers('bitcoin');
```
#### [getHistory](https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__history)
Get historical data (name, price, market, stats) at a given date for a coin
```php
$result = $client->coins()->getHistory('bitcoin', '30-12-2017');
```
#### [getMarketChart](https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__market_chart)
Get historical market data include price, market cap, and 24h volume (granularity auto)
```php
$result = $client->coins()->getMarketChart('bitcoin', 'usd', 'max');
```
#### [getMarketChartRange](https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__market_chart_range)
Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)
```php
$result = $client->coins()->getMarketChartRange('bitcoin', 'usd', '1392577232', '1422577232');
```
#### [getMarketChartRange](https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__status_updates) [BETA]
Get status updates for a given coin
```php
$result = $client->coins()->getStatusUpdates('0x');
```
### Contract
#### [getContract](https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address_)
Get coin info from contract address
```php
$data = $client->contract()->getContract('ethereum', '0xE41d2489571d322189246DaFA5ebDe1F4699F498');
```
#### [getMarketChart](https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address__market_chart_)
Get historical market data include price, market cap, and 24h volume (granularity auto) from a contract address
```php
$result = $client->contract()->getMarketChart('ethereum', '0xE41d2489571d322189246DaFA5ebDe1F4699F498', 'usd', '1');
```
#### [getMarketChartRange](https://www.coingecko.com/api/documentations/v3#/contract/get_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
```php
$result = $result = $client->contract()->getMarketChartRange('ethereum', '0xE41d2489571d322189246DaFA5ebDe1F4699F498', 'usd', '11392577232', ' 1422577232');
```
### Exchange [BETA]
#### [getExchanges](https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges)
List all exchanges
```php
$data = $client->exchanges()->getExchanges();
```
#### [getList](https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges_list)
List all supported markets id and name (no pagination required)
```php
$data = $client->exchanges()->getList();
```
#### [getExchange](https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges__id_)
Get exchange volume in BTC and top 100 tickers only
```php
$data = $client->exchanges()->getExchange('binance');
```
#### [getTickers](https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges__id__tickers)
Get exchange tickers (paginated)
```php
$data = $client->exchanges()->getTickers('binance', ['coin_ids' => '0x,bitcoin']);
```
#### [getStatusUpdates](https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges__id__status_updates)
Get status updates for a given exchange (beta)
```php
$data = $client->exchanges()->getStatusUpdates('binance');
```
#### [getVolumeChart](https://www.coingecko.com/api/documentations/v3#/exchanges_(beta)/get_exchanges__id__volume_chart)
Get volume_chart data for a given exchange (beta)
```php
$data = $client->exchanges()->getVolumeChart('binance', '1');
```
### Finance [BETA]
#### [getPlatforms](https://www.coingecko.com/api/documentations/v3#/finance_(beta)/get_finance_platforms)
List all finance platforms
```php
$data = $client->finance()->getPlatforms();
```
#### [getProducts](https://www.coingecko.com/api/documentations/v3#/finance_(beta)/get_finance_products)
List all finance products
```php
$data = $client->finance()->getProducts();
```
### Indexes [BETA]
#### [getIndexes](https://www.coingecko.com/api/documentations/v3#/indexes_(beta)/get_indexes)
List all market indexes
```php
$data = $client->indexes()->getIndexes();
```
#### [getIndex](https://www.coingecko.com/api/documentations/v3#/indexes_(beta)/get_indexes__id_)
Get market index by id
```php
$data = $client->indexes()->getIndex('BAT');
```
#### [getList](https://www.coingecko.com/api/documentations/v3#/indexes_(beta)/get_indexes_list)
List market indexes id and name
```php
$data = $client->indexes()->getList();
```
### Derivatives [BETA]
#### [getDerivatives](https://www.coingecko.com/api/documentations/v3#/derivatives_(beta)/get_derivatives)
List all derivative tickers
```php
$data = $client->derivatives()->getDerivatives();
```
#### [getExchanges](https://www.coingecko.com/api/documentations/v3#/derivatives_(beta)/get_derivatives_exchanges)
List all derivative exchanges
```php
$data = $client->derivatives()->getExchanges();
```
#### [getExchange](https://www.coingecko.com/api/documentations/v3#/derivatives_(beta)/get_derivatives_exchanges__id_)
Show derivative exchange data
```php
$data = $client->derivatives()->getExchange('binance_futures');
```
#### [getExchangeList](https://www.coingecko.com/api/documentations/v3#/derivatives_(beta)/get_derivatives_exchanges_list)
List all derivative exchanges name and identifier
```php
$data = $client->derivatives()->getExchangeList();
```
### Status updates [BETA]
#### [getStatusUpdates](https://www.coingecko.com/api/documentations/v3#/status_updates_(beta)/get_status_updates)
List all status_updates with data (description, category, created_at, user, user_title and pin)
```php
$data = $client->statusUpdates()->getStatusUpdates();
```
### Events [BETA]
#### [getEvents](https://www.coingecko.com/api/documentations/v3#/events/get_events)
Get events, paginated by 100
```php
$data = $client->events()->getEvents();
```
#### [getCountries](https://www.coingecko.com/api/documentations/v3#/events/get_events_countries)
Get list of event countries
```php
$data = $client->events()->getCountries();
```
#### [getTypes](https://www.coingecko.com/api/documentations/v3#/events/get_events_types)
Get list of events types
```php
$data = $client->events()->getTypes();
```
### Exchange rates [BETA]
#### [getExchangeRates](https://www.coingecko.com/api/documentations/v3#/exchange_rates/get_exchange_rates)
Get BTC-to-Currency exchange rates
```php
$data = $client->exchangeRates()->getExchangeRates();
```
### Global [BETA]
#### [getGlobal](https://www.coingecko.com/api/documentations/v3#/global/get_global)
Get cryptocurrency global data
```php
$data = $client->globals()->getGlobal();
```
## License
`codenix-sv/coingecko-api` is released under the MIT License. See the bundled [LICENSE](./LICENSE) for details.