forked from alexanderdavidpan/cryptocompare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
THONG NGO
76 lines (74 loc) · 2.34 KB
/
THONG NGO
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
require 'faraday'
require 'json'
module Cryptocompare
module CoinList
API_URL = 'https://min-api.cryptocompare.com/data/all/coinlist'
# Get general info for all the coins available on Cryptocompare's API.
#
# ==== Returns
#
# [Hash] Hash with data Data key which is a hash where coin symbols are the
# keys and each coin object cointains metadata about each coin.
#
# ==== Example
#
# Get all coins supported by Cryptocompare's API.
#
# Cryptocompare::CoinList.all
#
# Sample response
#
# {
# "Response" => "Success",
# "Message" => "Coin list succesfully returned!",
# "BaseImageUrl" => "https://www.cryptocompare.com",
# "BaseLinkUrl" => "https://www.cryptocompare.com",
# "DefaultWatchlist" => {
# "CoinIs" => "1182,7605,5038,24854,3807,3808,202330,5324,5031,20131",
# "Sponsored" => ""
# },
# "Data" => {
# "BTC" => {
# "Id" => "1182",
# "Url" => "/coins/btc/overview",
# "ImageUrl" => "/media/19633/btc.png",
# "Name" => "BTC",
# "Symbol" => "BTC",
# "CoinName" => "Bitcoin",
# "FullName" => "Bitcoin (BTC)",
# "Algorithm" => "SHA256",
# "ProofType" => "PoW",
# "FullyPremined" => "0",
# "TotalCoinSupply" => "21000000",
# "PreMinedValue" => "N/A",
# "TotalCoinsFreeFloat" => "N/A",
# "SortOrder" => "1",
# "Sponsored" => false
# },
# "ETH" => {
# "Id" => "7605",
# "Url" => "/coins/eth/overview",
# "ImageUrl" => "/media/20646/eth_logo.png",
# "Name" => "ETH",
# "Symbol" => "ETH",
# "CoinName" => "Ethereum ",
# "FullName" => "Ethereum (ETH)",
# "Algorithm" => "Ethash",
# "ProofType" => "PoW",
# "FullyPremined" => "0",
# "TotalCoinSupply" => "0",
# "PreMinedValue" => "N/A",
# "TotalCoinsFreeFloat" => "N/A",
# "SortOrder" => "2",
# "Sponsored" => false
# },
# ...
# },
# "Type" => 100
# }
def self.all
api_resp = Faraday.get(API_URL)
JSON.parse(api_resp.body)
end
end
end