Module: CoinmarketcapFree::Coin
- Defined in:
- lib/coinmarketcap_free/coin.rb
Overview
All about cryptocurrencies and their prices.
Constant Summary collapse
- URI_API =
"#{BASE_URI}#{VERSION_API}/cryptocurrency/listing"
Class Method Summary collapse
-
.list(**params) ⇒ String
Get a list of cryptocurrencies.
Class Method Details
.list(**params) ⇒ String
Get a list of cryptocurrencies
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1)
Result json:
{
"data": {
"cryptoCurrencyList": [
{
"id": 1,
"name": "Bitcoin",
"symbol": "BTC",
"slug": "bitcoin",
"tags": [
"mineable",
"pow",
"sha-256",
"store-of-value",
"state-channel",
"coinbase-ventures-portfolio",
"three-arrows-capital-portfolio",
"polychain-capital-portfolio",
"binance-labs-portfolio",
"blockchain-capital-portfolio",
"boostvc-portfolio",
"cms-holdings-portfolio",
"dcg-portfolio",
"dragonfly-capital-portfolio",
"electric-capital-portfolio",
"fabric-ventures-portfolio",
"framework-ventures-portfolio",
"galaxy-digital-portfolio",
"huobi-capital-portfolio",
"alameda-research-portfolio",
"a16z-portfolio",
"1confirmation-portfolio",
"winklevoss-capital-portfolio",
"usv-portfolio",
"placeholder-ventures-portfolio",
"pantera-capital-portfolio",
"multicoin-capital-portfolio",
"paradigm-portfolio"
],
"cmcRank": 1,
"marketPairCount": 9922,
"circulatingSupply": 19256812.0,
"selfReportedCirculatingSupply": 0,
"totalSupply": 19256812.0,
"maxSupply": 21000000.0,
"isActive": 1,
"lastUpdated": "2023-01-09T08:25:00.000Z",
"dateAdded": "2013-04-28T00:00:00.000Z",
"quotes": [
{
"name": "USD",
"price": 17209.447088639048,
"volume24h": 13652714044.770432,
"marketCap": 331399087209.8695,
"percentChange1h": -0.00692023,
"percentChange24h": 1.50954046,
"percentChange7d": 2.78181713,
"lastUpdated": "2023-01-09T08:25:00.000Z",
"percentChange30d": 0.30441134,
"percentChange60d": 3.89490715,
"percentChange90d": -9.99714982,
"fullyDilluttedMarketCap": 361398388861.42,
"marketCapByTotalSupply": 331399087209.8695,
"dominance": 39.0828,
"turnover": 0.0411972,
"ytdPriceChangePercentage": 3.515
}
],
"isAudited": false
}
...
],
"totalCount": "8857"
},
"status": {
"timestamp": "2023-01-08T15:33:30.271Z",
"error_code": "0",
"error_message": "SUCCESS",
"elapsed": "2",
"credit_count": 0
}
}
‘data’ - Results of your query returned as an object map. ‘cryptoCurrencyList’ - Array of cryptocurrency objects matching the list options. ‘totalCount’ - Total number of cryptocurrencies ‘status’ - Standardized status object for API calls.
If you want to sort in ascending, just write parameter:
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc')
or
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'desc')
You can also adding sort by:
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, sort_type:'asc', sort_by: 'name')
- Convert cryptocurrency to
-
list = CoinmarketcapFree::Coin.list(limit: 100, start: 1, convert: ‘USD,BTC,ETH’)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/coinmarketcap_free/coin.rb', line 137 def list(**params) = {} [:start] = params[:start] || 1 # Integer [:limit] = params[:limit] || 100 # Integer [:sortBy] = params[:sort_by] || 'market_cap' # String [:sortType] = params[:sort_type] || 'desc' # String [:convert] = params[:convert] || 'USD' # String [:cryptoType] = params[:crypto_type] || 'all' # String [:tagType] = params[:tag_type] || 'all' # String [:audited] = params[:audited] || false # Boolean [:aux] = params[:aux] # String [:tags] = params[:tags] # String [:volume24hRange] = params[:volume24h_range] # String [:percentChange24hRange] = params[:percent_change24h_range] # String [:circulatingSupplyRange] = params[:circulating_supply_range] # String [:priceRange] = params[:price_range] # String [:marketCapRange] = params[:market_cap_range] # String Helper.http_get(URI_API, ) end |