Skip to content

Commit

Permalink
Merge 678fa4d into 5f29fbd
Browse files Browse the repository at this point in the history
  • Loading branch information
lrosskamp committed Mar 30, 2018
2 parents 5f29fbd + 678fa4d commit 965a789
Showing 1 changed file with 137 additions and 4 deletions.
141 changes: 137 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

# Coinmarketcap

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/coinmarketcap`. To experiment with that code, run `bin/console` for an interactive prompt.

TODO: Delete this and the text above, and describe your gem
A ruby wrapper for the [coinmarketcap.com API](https://coinmarketcap.com/api/).

## Installation

Expand All @@ -24,7 +22,142 @@ Or install it yourself as:

## Usage

TODO: Write usage instructions here
### Coins
To get information for multiple coins use the `coins` method.

**Parameters**

| Name | Type | Description |
| :------------- | :------------- | :------------- |
| `limit` | int | Return a maximum of `limit` results (default is 100, use 0 to return all results) |

**Sample Response**
```json
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "573.137",
"price_btc": "1.0",
"24h_volume_usd": "72855700.0",
"market_cap_usd": "9080883500.0",
"available_supply": "15844176.0",
"total_supply": "15844176.0",
"percent_change_1h": "0.04",
"percent_change_24h": "-0.3",
"percent_change_7d": "-0.57",
"last_updated": "1472762067"
},
{
"id": "ethereum",
"name": "Ethereum",
"symbol": "ETH",
"rank": "2",
"price_usd": "12.1844",
"price_btc": "0.021262",
"24h_volume_usd": "24085900.0",
"market_cap_usd": "1018098455.0",
"available_supply": "83557537.0",
"total_supply": "83557537.0",
"percent_change_1h": "-0.58",
"percent_change_24h": "6.34",
"percent_change_7d": "8.59",
"last_updated": "1472762062"
},
...
]
```

**Examples**
```ruby
Coinmarketcap.coins
#=> returns array of 100 coins

Coinmarketcap.coins(0)
#=> returns array of all available coins

Coinmarketcap.coins(20)
#=> returns array of only 20 coins
```

### Coin
To get information for a specific coin use the `coin` method.

**Parameters**

| Name | Type | Description |
| :------------- | :------------- | :------------- |
| `id` | string | **required**. Return information for coin with `id` |
| `currency` | string | return *price*, *24h volume*, and *market cap* in terms of another currency. Valid values are "AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR". (default is "USD") |

**Sample Response**
```json
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "573.137",
"price_btc": "1.0",
"24h_volume_usd": "72855700.0",
"market_cap_usd": "9080883500.0",
"available_supply": "15844176.0",
"total_supply": "15844176.0",
"max_supply": "21000000.0",
"percent_change_1h": "0.04",
"percent_change_24h": "-0.3",
"percent_change_7d": "-0.57",
"last_updated": "1472762067"
}
]
```

**Examples**
```ruby
Coinmarketcap.coin('BTC')
#=> returns information about coin with 'BTC' as its ticker symbol.
# Price, 24h volume and market cap are in USD

Coinmarketcap.coin('BTC', 'EUR')
#=> returns information about coin with 'BTC' as its ticker symbol.
# Price, 24h volume and market cap are in EUR
```

### Global
To get global (general) data, use the `global` method.

**Parameters**

| Name | Type | Description |
| :------------- | :------------- | :------------- |
| `currency` | string | return *price*, *24h volume*, and *market cap* in terms of another currency. Valid values are "AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR". (default is "USD") |

**Sample Response**
```json
{
"total_market_cap_usd": 201241796675,
"total_24h_volume_usd": 4548680009,
"bitcoin_percentage_of_market_cap": 62.54,
"active_currencies": 896,
"active_assets": 360,
"active_markets": 6439,
"last_updated": 1509909852
}
```

**Examples**
```ruby
Coinmarketcap.global
#=> returns global data
# Price, 24h volume and market cap are in USD

Coinmarketcap.global('EUR')
#=> returns global data
# Price, 24h volume and market cap are in EUR
```

## Development

Expand Down

0 comments on commit 965a789

Please sign in to comment.