coingecko_ruby 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/coingecko_ruby.gemspec +1 -1
- data/lib/coingecko_ruby.rb +1 -1
- data/lib/coingecko_ruby/client.rb +4 -0
- data/lib/coingecko_ruby/client/categories.rb +406 -0
- data/lib/coingecko_ruby/client/coins.rb +214 -12
- data/lib/coingecko_ruby/client/exchanges.rb +1600 -0
- data/lib/coingecko_ruby/client/prices.rb +484 -8
- data/lib/coingecko_ruby/client/status.rb +6 -0
- data/lib/coingecko_ruby/connection.rb +7 -5
- data/lib/coingecko_ruby/version.rb +1 -1
- metadata +5 -2
@@ -1,26 +1,502 @@
|
|
1
1
|
module CoingeckoRuby
|
2
2
|
class Client
|
3
3
|
module Prices
|
4
|
-
|
5
|
-
|
4
|
+
# Fetches the current price for a coin in the given coin or currency.
|
5
|
+
# @param id [String] the coin id to fetch.
|
6
|
+
# @param currency [String] the currency to display the coin's price.
|
7
|
+
# @option options [Boolean] :include_market_cap include market cap data.
|
8
|
+
# @option options [Boolean] :include_24hr_vol include 24 hour volume data.
|
9
|
+
# @option options [Boolean] :include_24hr_change include 24 hour price change data.
|
10
|
+
# @option options [Boolean] :include_last_updated_at include last updated at value for the given coin.
|
11
|
+
#
|
12
|
+
# @return [Hash] returns the given coin id and its current price.
|
13
|
+
#
|
14
|
+
# @example Fetch the current price in USD for Bitcoin.
|
15
|
+
# client.get_price(id: 'bitcoin', currency: 'usd')
|
16
|
+
# @example Response object
|
17
|
+
# {
|
18
|
+
# "bitcoin" => {
|
19
|
+
# "usd" => 47931 # current price in given currency
|
20
|
+
# }
|
21
|
+
# }
|
22
|
+
# @example Fetch the current price, market cap, 24 hour volume, 24 hour price change and last updated at for Bitcoin.
|
23
|
+
# client.get_price(id: 'bitcoin', currency: 'usd', options: { include_market_cap: true, include_24hr_vol: true, include_24hr_change: true, include_last_updated_at: true })
|
24
|
+
# @example Response object
|
25
|
+
# {
|
26
|
+
# "bitcoin" => {
|
27
|
+
# "usd" => 48217, # current price in given currency
|
28
|
+
# "usd_market_cap" => 905542853013.7438, # market cap in given currency
|
29
|
+
# "usd_24h_vol" => 66724791943.1098, # 24 hour volume in given currency
|
30
|
+
# "usd_24h_change" => -2.813036070702345, # 24 hour price change percentage
|
31
|
+
# "last_updated_at" => 1621142197 # last updated at UNIX timestamp for the given coin
|
32
|
+
# }
|
33
|
+
# }
|
34
|
+
def get_price(id:, currency: 'usd', options: {})
|
35
|
+
get 'simple/price', { ids: id, vs_currencies: currency, options: options }
|
6
36
|
end
|
7
37
|
|
38
|
+
# Fetches historical price data for a coin at a given date.
|
39
|
+
# @param id [String] the coin id to fetch.
|
40
|
+
# @param date [String] the date to fetch the historical price, date given must be in the form of 'DD-MM-YYYY' (e.g: '14-05-2021').
|
41
|
+
#
|
42
|
+
# @return [Hash] returns the coin's historical price data on the given date.
|
43
|
+
#
|
44
|
+
# @example Fetch Bitcoin's price on 30th December, 2017.
|
45
|
+
# client.get_historical_price_on_date(id: 'bitcoin', date: '30-12-2017')
|
46
|
+
# @example Response object (truncated)
|
47
|
+
# {
|
48
|
+
# "id": "bitcoin",
|
49
|
+
# "symbol": "btc",
|
50
|
+
# "name": "Bitcoin",
|
51
|
+
# "localization": {
|
52
|
+
# "en": "Bitcoin",
|
53
|
+
# "de": "Bitcoin",
|
54
|
+
# "es": "Bitcoin",
|
55
|
+
# "fr": "Bitcoin",
|
56
|
+
# "it": "Bitcoin",
|
57
|
+
# "pl": "Bitcoin",
|
58
|
+
# "ro": "Bitcoin",
|
59
|
+
# "hu": "Bitcoin",
|
60
|
+
# "nl": "Bitcoin",
|
61
|
+
# "pt": "Bitcoin",
|
62
|
+
# "sv": "Bitcoin",
|
63
|
+
# "vi": "Bitcoin",
|
64
|
+
# "tr": "Bitcoin",
|
65
|
+
# "ru": "биткоин",
|
66
|
+
# "ja": "ビットコイン",
|
67
|
+
# "zh": "比特币",
|
68
|
+
# "zh-tw": "比特幣",
|
69
|
+
# "ko": "비트코인",
|
70
|
+
# "ar": "بيتكوين",
|
71
|
+
# "th": "บิตคอยน์",
|
72
|
+
# "id": "Bitcoin"
|
73
|
+
# },
|
74
|
+
# "image": {
|
75
|
+
# "thumb": "https://assets.coingecko.com/coins/images/1/thumb/bitcoin.png?1547033579",
|
76
|
+
# "small": "https://assets.coingecko.com/coins/images/1/small/bitcoin.png?1547033579"
|
77
|
+
# },
|
78
|
+
# "market_data": {
|
79
|
+
# "current_price": {
|
80
|
+
# "aed": 50024.57906376443,
|
81
|
+
# "ars": 253468.12429692186,
|
82
|
+
# "aud": 17446.3215245937,
|
83
|
+
# "bch": 5.76928286478153,
|
84
|
+
# "bdt": 1126110.803183989,
|
85
|
+
# "bhd": 5132.860612995706,
|
86
|
+
# "bmd": 13620.3618741461,
|
87
|
+
# "brl": 45117.7211153463,
|
88
|
+
# "btc": 1,
|
89
|
+
# "cad": 17128.871750393,
|
90
|
+
# "chf": 13262.4868659029,
|
91
|
+
# "clp": 8362902.190725706,
|
92
|
+
# "cny": 88573.2132675718,
|
93
|
+
# "czk": 289914.5782287119,
|
94
|
+
# "dkk": 84525.1736167662,
|
95
|
+
# "eth": 18.483094024188404,
|
96
|
+
# "eur": 11345.8976447824,
|
97
|
+
# "gbp": 10079.0677868681,
|
98
|
+
# "hkd": 106417.930376984,
|
99
|
+
# "huf": 3526720.3000726495,
|
100
|
+
# "idr": 184652192.175199,
|
101
|
+
# "ils": 47387.96303252911,
|
102
|
+
# "inr": 869671.001953725,
|
103
|
+
# "jpy": 1535062.45448282,
|
104
|
+
# "krw": 14537693.2463698,
|
105
|
+
# "kwd": 4104.645874754543,
|
106
|
+
# "lkr": 2087919.548829924,
|
107
|
+
# "ltc": 60.96840666846534,
|
108
|
+
# "mmk": 18414729.253845528,
|
109
|
+
# "mxn": 267888.750532982,
|
110
|
+
# "myr": 55317.8739192755,
|
111
|
+
# "ngn": 4884546.501733771,
|
112
|
+
# "nok": 111755.75019546246,
|
113
|
+
# "nzd": 19178.1505368914,
|
114
|
+
# "php": 680527.760679833,
|
115
|
+
# "pkr": 1505414.7676248574,
|
116
|
+
# "pln": 47450.61669715,
|
117
|
+
# "rub": 785377.30638701,
|
118
|
+
# "sar": 51079.0811004227,
|
119
|
+
# "sek": 111446.704184538,
|
120
|
+
# "sgd": 18213.1478981081,
|
121
|
+
# "thb": 442954.59869004245,
|
122
|
+
# "try": 51700.07425935065,
|
123
|
+
# "twd": 404053.46952093,
|
124
|
+
# "uah": 382908.08925747185,
|
125
|
+
# "usd": 13620.3618741461,
|
126
|
+
# "vef": 140859.73944813784,
|
127
|
+
# "vnd": 309201434.91677517,
|
128
|
+
# "xag": 804.154745877564,
|
129
|
+
# "xau": 10.4549897745945,
|
130
|
+
# "xdr": 9563.95932114975,
|
131
|
+
# "zar": 168771.061713303,
|
132
|
+
# "bits": 1000000,
|
133
|
+
# "link": 22041.447552365687,
|
134
|
+
# "sats": 100000000
|
135
|
+
# },
|
136
|
+
# "market_cap": {
|
137
|
+
# "aed": 839030999274.6053,
|
138
|
+
# "ars": 4251262431254.5815,
|
139
|
+
# "aud": 292616246981.057,
|
140
|
+
# "bch": 96764575.68919012,
|
141
|
+
# "bdt": 18887552682553.043,
|
142
|
+
# "bhd": 86090263023.8938,
|
143
|
+
# "bmd": 228445816988.881,
|
144
|
+
# "brl": 756731337692.006,
|
145
|
+
# "btc": 16772375,
|
146
|
+
# "cad": 287291860324.498,
|
147
|
+
# "chf": 222443403147.498,
|
148
|
+
# "clp": 140265731631172.94,
|
149
|
+
# "cny": 1485583147878.69,
|
150
|
+
# "czk": 4862556024018.788,
|
151
|
+
# "dkk": 1417687908840.51,
|
152
|
+
# "eth": 310005384.13394696,
|
153
|
+
# "eur": 190297650009.907,
|
154
|
+
# "gbp": 169049904571.772,
|
155
|
+
# "hkd": 1784881435006.67,
|
156
|
+
# "huf": 59151475392930.96,
|
157
|
+
# "idr": 3097055811734500,
|
158
|
+
# "ils": 794808686467.7148,
|
159
|
+
# "inr": 14586448171393.6,
|
160
|
+
# "jpy": 25746643135006.3,
|
161
|
+
# "krw": 243831642763082,
|
162
|
+
# "kwd": 68844659853.58617,
|
163
|
+
# "lkr": 35019369642806.27,
|
164
|
+
# "ltc": 1022584979.7960014,
|
165
|
+
# "mmk": 308858744568967.1,
|
166
|
+
# "mxn": 4493130582220.62,
|
167
|
+
# "myr": 927812125576.808,
|
168
|
+
# "ngn": 81925445632016.88,
|
169
|
+
# "nok": 1874409350684.6182,
|
170
|
+
# "nzd": 321663132611.194,
|
171
|
+
# "php": 11414066800032.4,
|
172
|
+
# "pkr": 25249381013141.95,
|
173
|
+
# "pln": 795859537225.861,
|
174
|
+
# "rub": 13172642699212.8,
|
175
|
+
# "sar": 856717502871.7015,
|
176
|
+
# "sek": 1869225915097.14,
|
177
|
+
# "sgd": 305477746477.531,
|
178
|
+
# "thb": 7429400637203.895,
|
179
|
+
# "try": 867133033005.6757,
|
180
|
+
# "twd": 6776936310856.11,
|
181
|
+
# "uah": 6422278063559.784,
|
182
|
+
# "usd": 228445816988.881,
|
183
|
+
# "vef": 2362552372426.4595,
|
184
|
+
# "vnd": 5186042416962243,
|
185
|
+
# "xag": 13487584955.8882,
|
186
|
+
# "xau": 175355009.120664,
|
187
|
+
# "xdr": 160410312219.069,
|
188
|
+
# "zar": 2830691536203.66,
|
189
|
+
# "bits": 16772375000000,
|
190
|
+
# "link": 369687423891.10944,
|
191
|
+
# "sats": 1677237500000000
|
192
|
+
# },
|
193
|
+
# "total_volume": {
|
194
|
+
# "aed": 13223772038.888288,
|
195
|
+
# "ars": 67003156399.47071,
|
196
|
+
# "aud": 4611856472.88116,
|
197
|
+
# "bch": 1525083.9259334763,
|
198
|
+
# "bdt": 297682315984.16693,
|
199
|
+
# "bhd": 1356848571.721612,
|
200
|
+
# "bmd": 3600481281.03768,
|
201
|
+
# "brl": 11926666253.0629,
|
202
|
+
# "btc": 264345.493482963,
|
203
|
+
# "cad": 4527940055.66402,
|
204
|
+
# "chf": 3505878635.37842,
|
205
|
+
# "clp": 2210695506557.1357,
|
206
|
+
# "cny": 23413929770.588,
|
207
|
+
# "czk": 76637612249.77382,
|
208
|
+
# "dkk": 22343848731.4572,
|
209
|
+
# "eth": 4885922.610916088,
|
210
|
+
# "eur": 2999236911.91719,
|
211
|
+
# "gbp": 2664356147.96788,
|
212
|
+
# "hkd": 28131100320.9394,
|
213
|
+
# "huf": 932272618099.0865,
|
214
|
+
# "idr": 48811974863263.9,
|
215
|
+
# "ils": 12526794472.986298,
|
216
|
+
# "inr": 229893610179.28,
|
217
|
+
# "jpy": 405786842057.429,
|
218
|
+
# "krw": 3842973695315.56,
|
219
|
+
# "kwd": 1085044639.3347962,
|
220
|
+
# "lkr": 551932123488.1709,
|
221
|
+
# "ltc": 16116723.547645444,
|
222
|
+
# "mmk": 4867850691962.943,
|
223
|
+
# "mxn": 70815183958.1755,
|
224
|
+
# "myr": 14623030679.6192,
|
225
|
+
# "ngn": 1291207855441.2922,
|
226
|
+
# "nok": 29542128934.978218,
|
227
|
+
# "nzd": 5069657667.76511,
|
228
|
+
# "php": 179894446725.766,
|
229
|
+
# "pkr": 397949609644.3324,
|
230
|
+
# "pln": 12543356686.879,
|
231
|
+
# "rub": 207610951627.194,
|
232
|
+
# "sar": 13502524900.147509,
|
233
|
+
# "sek": 29460434014.7115,
|
234
|
+
# "sgd": 4814563569.00357,
|
235
|
+
# "thb": 117093051981.26692,
|
236
|
+
# "try": 13666681643.19386,
|
237
|
+
# "twd": 106809713794.014,
|
238
|
+
# "uah": 101220027813.38469,
|
239
|
+
# "usd": 3600481281.03768,
|
240
|
+
# "vef": 37235637336.29954,
|
241
|
+
# "vnd": 81736005898715.08,
|
242
|
+
# "xag": 212574683.135671,
|
243
|
+
# "xau": 2763729.43132451,
|
244
|
+
# "xdr": 2528189546.40031,
|
245
|
+
# "zar": 44613869594.2467,
|
246
|
+
# "bits": 264345493482.963,
|
247
|
+
# "link": 5826557330.308955,
|
248
|
+
# "sats": 26434549348296.3
|
249
|
+
# }
|
250
|
+
# },
|
251
|
+
# "community_data": {
|
252
|
+
# "facebook_likes": null,
|
253
|
+
# "twitter_followers": 603664,
|
254
|
+
# "reddit_average_posts_48h": 2.042,
|
255
|
+
# "reddit_average_comments_48h": 445.896,
|
256
|
+
# "reddit_subscribers": 612412,
|
257
|
+
# "reddit_accounts_active_48h": "14074.0"
|
258
|
+
# },
|
259
|
+
# "developer_data": {
|
260
|
+
# "forks": 13660,
|
261
|
+
# "stars": 23665,
|
262
|
+
# "subscribers": 2513,
|
263
|
+
# "total_issues": 3591,
|
264
|
+
# "closed_issues": 3022,
|
265
|
+
# "pull_requests_merged": 5038,
|
266
|
+
# "pull_request_contributors": 450,
|
267
|
+
# "code_additions_deletions_4_weeks": {
|
268
|
+
# "additions": null,
|
269
|
+
# "deletions": null
|
270
|
+
# },
|
271
|
+
# "commit_count_4_weeks": 147
|
272
|
+
# },
|
273
|
+
# "public_interest_stats": {
|
274
|
+
# "alexa_rank": 2912,
|
275
|
+
# "bing_matches": null
|
276
|
+
# }
|
277
|
+
# }
|
8
278
|
def get_historical_price_on_date(id:, date:)
|
9
279
|
get("coins/#{id}/history", { query: { date: date } })
|
10
280
|
end
|
11
281
|
|
12
|
-
|
13
|
-
|
282
|
+
# Fetches a coin's historical price data in 5 - 10 minutes ranges.
|
283
|
+
# @note Minutely historical data is only available within the last 24 hours.
|
284
|
+
# @param id [String] the coin id to fetch.
|
285
|
+
# @param currency [String] the currency used to display minutely historical price.
|
286
|
+
#
|
287
|
+
# @return [Hash] returns the coin's minutely historical price data within the last 24 hours.
|
288
|
+
#
|
289
|
+
# @example Fetch Bitcoin's minutely historical price within the last 24 hours.
|
290
|
+
# client.get_minutely_historical_prices(id: 'bitcoin')
|
291
|
+
# @example Response object (truncated)
|
292
|
+
# {
|
293
|
+
# "prices" => [
|
294
|
+
# [1621057474114, 49364.605172521166], # [UNIX timestamp for minutely price data, coin price in given currency]
|
295
|
+
# [1621057731319, 49482.24672699064],
|
296
|
+
# [1621058047104, 49759.16253913667],
|
297
|
+
# ],
|
298
|
+
# "market_caps" => [
|
299
|
+
# [1621057474114, 923529491095.7441],
|
300
|
+
# [1621057731319, 923529491095.7441],
|
301
|
+
# [1621058047104, 925839705121.9677],
|
302
|
+
# ],
|
303
|
+
# "total_volumes" => [
|
304
|
+
# [1621057474114, 55351845301.87241],
|
305
|
+
# [1621057731319, 55565821585.076706],
|
306
|
+
# [1621058047104, 57046967935.326035],
|
307
|
+
# ]
|
308
|
+
# }
|
309
|
+
def get_minutely_historical_prices(id:, currency: 'usd')
|
310
|
+
get "coins/#{id}/market_chart", { id: id, vs_currency: currency, days: 1 }
|
14
311
|
end
|
15
312
|
|
16
|
-
|
313
|
+
# Fetches a coin's historical price data in 1 hour ranges.
|
314
|
+
# @note Hourly historical data is only available within the last 90 days.
|
315
|
+
# @param id [String] the coin id to fetch.
|
316
|
+
# @param days [Integer] the number of days to fetch hourly historical prices (min: 1 day, max: 90 days)
|
317
|
+
# @param currency [String] the currency used to display hourly historical price.
|
318
|
+
#
|
319
|
+
# @return [Hash] returns the coin's hourly historical price data within the number of days given.
|
320
|
+
#
|
321
|
+
# @example Fetch Bitcoin's hourly historical price within the last 7 days.
|
322
|
+
# client.get_hourly_historical_prices(id: 'bitcoin', days: 7)
|
323
|
+
# @example Response object (truncated)
|
324
|
+
# {
|
325
|
+
# "prices" => [
|
326
|
+
# [1620540153122, 58533.64354969528], # [UNIX timestamp for minutely price data, coin price in given currency]
|
327
|
+
# [1620543723872, 58384.26782776662],
|
328
|
+
# [1620547381049, 58022.030773147424],
|
329
|
+
# ], "market_caps" => [
|
330
|
+
# [1620540153122, 1094831531450.288],
|
331
|
+
# [1620543723872, 1092040480555.5005],
|
332
|
+
# [1620547381049, 1085268316789.8125],
|
333
|
+
# ], "total_volumes" => [
|
334
|
+
# [1620540153122, 71975097904.11748],
|
335
|
+
# [1620543723872, 72192190625.33702],
|
336
|
+
# [1620547381049, 72064327648.28767],
|
337
|
+
# ]
|
338
|
+
# }
|
339
|
+
def get_hourly_historical_prices(id:, days:, currency: 'usd')
|
17
340
|
return get_daily_historical_prices(id: id, days: days) if days > 90
|
18
341
|
|
19
|
-
get
|
342
|
+
get "coins/#{id}/market_chart", { vs_currency: currency, days: days }
|
20
343
|
end
|
21
344
|
|
22
|
-
|
23
|
-
|
345
|
+
# Fetches a coin's historical price data in daily ranges.
|
346
|
+
# @param id [String] the coin id to fetch.
|
347
|
+
# @param days [Integer] the number of days to fetch daily historical prices.
|
348
|
+
# @param currency [String] the currency used to display daily historical price.
|
349
|
+
#
|
350
|
+
# @return [Hash] returns the coin's daily historical price data within the number of days given.
|
351
|
+
#
|
352
|
+
# @example Fetch Bitcoin's daily historical price within the last 14 days.
|
353
|
+
# client.get_daily_historical_prices(id: 'bitcoin', days: 14)
|
354
|
+
# {
|
355
|
+
# "prices" => [
|
356
|
+
# [1620000000000, 56600.74528738432], # [UNIX timestamp for minutely price data, coin price in given currency]
|
357
|
+
# [1620086400000, 57200.30029871162],
|
358
|
+
# [1620172800000, 53464.37021950372],
|
359
|
+
# ], "market_caps" => [
|
360
|
+
# [1620000000000, 1057850321948.5465],
|
361
|
+
# [1620086400000, 1069571255195.5189],
|
362
|
+
# [1620172800000, 999775008412.3738],
|
363
|
+
# ], "total_volumes" => [
|
364
|
+
# [1620000000000, 39072664393.929405],
|
365
|
+
# [1620086400000, 54132470274.07509],
|
366
|
+
# [1620172800000, 71296763919.13268],
|
367
|
+
# ]
|
368
|
+
# }
|
369
|
+
def get_daily_historical_prices(id:, days:, currency: 'usd')
|
370
|
+
get "coins/#{id}/market_chart", { vs_currency: currency, days: days, interval: 'daily' }
|
371
|
+
end
|
372
|
+
|
373
|
+
# Fetches a coin's open, high, low, and close (OHLC) data within the number of days given.
|
374
|
+
# @param id [String] the coin id to fetch.
|
375
|
+
# @param days [Integer, String] the number of days to fetch daily historical prices. Valid values: 1/7/14/30/90/180/365/'max'
|
376
|
+
# @param currency [String] the currency to display OHLC data.
|
377
|
+
#
|
378
|
+
# @return [Array<Array<String, Float>>] returns the coin's OHLC data within the number of days given.
|
379
|
+
# If the number of days given is between 1-2 days, the OHLC data is returned in 30-minute intervals.
|
380
|
+
# If the number of days given is between 3-30 days, the OHLC data is returned in 4-hour intervals.
|
381
|
+
# If the number of days given is more than 30 days, the OHLC data is returned in 4-day intervals.
|
382
|
+
#
|
383
|
+
# @example Fetch Bitcoin's OHLC data in USD within the last 7 days.
|
384
|
+
# client.get_ohlc(id: 'bitcoin', days: 7, currency: 'usd')
|
385
|
+
# @example Response object (truncated)
|
386
|
+
# [
|
387
|
+
# [1620547200000, 58384.27, 58384.27, 58384.27, 58384.27], # [UNIX timestamp for OHLC data, open, high, low, close]
|
388
|
+
# [1620561600000, 58022.03, 58214.96, 57943.18, 58048.35],
|
389
|
+
# [1620576000000, 57956.7, 57956.7, 56636.68, 57302.22],
|
390
|
+
# [1620590400000, 57396.24, 57618.74, 57396.24, 57535.26],
|
391
|
+
# [1620604800000, 57347.57, 58071.98, 57347.57, 58050.13],
|
392
|
+
# [1620619200000, 58213.93, 59005.01, 58213.93, 58909.0],
|
393
|
+
# [1620633600000, 59577.8, 59577.8, 58849.82, 58849.82],
|
394
|
+
# [1620648000000, 58495.02, 58495.02, 57878.12, 57878.12],
|
395
|
+
# [1620662400000, 58239.57, 58239.57, 57237.93, 57237.93],
|
396
|
+
# [1620676800000, 58114.79, 58114.79, 56850.29, 56850.29],
|
397
|
+
# ]
|
398
|
+
def get_ohlc(id:, days:, currency: 'usd')
|
399
|
+
get "coins/#{id}/ohlc", { vs_currency: currency, days: days }
|
400
|
+
end
|
401
|
+
|
402
|
+
# Fetches the list of currencies currently supported by CoinGecko's API.
|
403
|
+
#
|
404
|
+
# @return [Array<String>] returns the list of currencies currently supported by CoinGecko's API.
|
405
|
+
#
|
406
|
+
# @example Fetch supported currencies.
|
407
|
+
# client.supported_currencies
|
408
|
+
# @example Response object
|
409
|
+
# [
|
410
|
+
# "btc",
|
411
|
+
# "eth",
|
412
|
+
# "ltc",
|
413
|
+
# "bch",
|
414
|
+
# "bnb",
|
415
|
+
# "eos",
|
416
|
+
# "xrp",
|
417
|
+
# "xlm",
|
418
|
+
# "link",
|
419
|
+
# "dot",
|
420
|
+
# "yfi",
|
421
|
+
# "usd",
|
422
|
+
# "aed",
|
423
|
+
# "ars",
|
424
|
+
# "aud",
|
425
|
+
# "bdt",
|
426
|
+
# "bhd",
|
427
|
+
# "bmd",
|
428
|
+
# "brl",
|
429
|
+
# "cad",
|
430
|
+
# "chf",
|
431
|
+
# "clp",
|
432
|
+
# "cny",
|
433
|
+
# "czk",
|
434
|
+
# "dkk",
|
435
|
+
# "eur",
|
436
|
+
# "gbp",
|
437
|
+
# "hkd",
|
438
|
+
# "huf",
|
439
|
+
# "idr",
|
440
|
+
# "ils",
|
441
|
+
# "inr",
|
442
|
+
# "jpy",
|
443
|
+
# "krw",
|
444
|
+
# "kwd",
|
445
|
+
# "lkr",
|
446
|
+
# "mmk",
|
447
|
+
# "mxn",
|
448
|
+
# "myr",
|
449
|
+
# "ngn",
|
450
|
+
# "nok",
|
451
|
+
# "nzd",
|
452
|
+
# "php",
|
453
|
+
# "pkr",
|
454
|
+
# "pln",
|
455
|
+
# "rub",
|
456
|
+
# "sar",
|
457
|
+
# "sek",
|
458
|
+
# "sgd",
|
459
|
+
# "thb",
|
460
|
+
# "try",
|
461
|
+
# "twd",
|
462
|
+
# "uah",
|
463
|
+
# "vef",
|
464
|
+
# "vnd",
|
465
|
+
# "zar",
|
466
|
+
# "xdr",
|
467
|
+
# "xag",
|
468
|
+
# "xau",
|
469
|
+
# "bits",
|
470
|
+
# "sats"
|
471
|
+
# ]
|
472
|
+
def supported_currencies
|
473
|
+
get('simple/supported_vs_currencies')
|
474
|
+
end
|
475
|
+
|
476
|
+
# Fetches the exchange rate for a coin or currency in the given coin or currency.
|
477
|
+
# @param from [String] the coin id or currency to be converted.
|
478
|
+
# @param to [String] the coin id or currency to convert against.
|
479
|
+
#
|
480
|
+
# @return [Hash] returns the coin's exchange rate against the given coin or currency.
|
481
|
+
#
|
482
|
+
# @example Fetch the exchange rate for BTC-USD.
|
483
|
+
# client.get_exchange_rate(from: 'bitcoin', to: 'usd')
|
484
|
+
# @example Response object
|
485
|
+
# {
|
486
|
+
# "bitcoin" => {
|
487
|
+
# "usd" => 47931 # current price in given currency
|
488
|
+
# }
|
489
|
+
# }
|
490
|
+
# @example Fetch the exchange rate for BTC-ETH.
|
491
|
+
# client.get_exchange_rate(from: 'bitcoin', to: 'eth')
|
492
|
+
# @example Response object
|
493
|
+
# {
|
494
|
+
# "bitcoin" => {
|
495
|
+
# "eth" => 12.71434 # current price in given currency
|
496
|
+
# }
|
497
|
+
# }
|
498
|
+
def get_exchange_rate(from:, to: 'usd')
|
499
|
+
get_price(id: from, currency: to)
|
24
500
|
end
|
25
501
|
end
|
26
502
|
end
|