-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
222 lines (150 loc) · 4.43 KB
/
README.Rmd
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
---
title: "CoinGeckoR"
output: github_document
---
<a><img src="images/CoinGecko_Logo.png" align="left" height="100" width="100" ></a>
### R functions for interacting with the CoinGecko API
**Powered by** [CoinGecko](https://www.coingecko.com/). *Currently under development*
These functions should be used in conjunction with the [CoinGecko API documentation](https://www.coingecko.com/api/documentations/v3).
---
### Installation
---
GitHub
```{r, eval=FALSE}
library(devtools)
install_github("https://github.com/SamBuckberry/CoinGeckoR")
```
```{r}
library(CoinGeckoR)
```
---
### CoinGeckoR functions
The functions listed below correspond to the list in the [CoinGecko API documentation](https://www.coingecko.com/api/documentations/v3).
---
#### Ping
- `/simple/ping` Check API server status
```{r}
ping_gecko()
```
---
#### Simple
- `/simple/price` Get the current price of any cryptocurrencies in any other supported currencies that you need.
```{r, results='hide'}
price(ids = "bitcoin", vs_currencies = "usd")
```
- `/simple/token_price/{id}` Get current price of tokens (using contract addresses) for a given platform in any other currency that you need.
```{r, results='hide'}
```
- `/simple/supported_vs_currencies` Get list of supported_vs_currencies
```{r, results='hide'}
supported_vs_currencies()
```
---
#### Coins
- `/coins/list` List all supported coins id, name and symbol.
```{r, results='hide'}
coins_list()
```
- `/coins/markets` List all supported coins price, market cap, volume, and market related data.
```{r, results='hide'}
markets(vs_currency = "usd", ids = "bitcoin")
```
- `/coins/{id}` Get current data (name, price, market, ... including exchange tickers) for a coin.
```{r, results='hide'}
coins_data(id = "bitcoin")
```
- `/coins/{id}/tickers` Get coin tickers (paginated to 100 items).
This function returns a lot of information!
```{r, results='hide'}
coins_tickers(id="bitcoin")
```
- `/coins/{id}/market_chart` Get historical market data include price, market cap, and 24h volume (granularity auto)
```{r, results='hide'}
coins_chart(id = "bitcoin", currency = "usd", days = 30)
```
- `/coins/{id}/market_chart/range` Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto)
```{r, results='hide'}
```
- `/coins/{id}/status_updates` Get status updates for a given coin
```{r, results='hide'}
```
- `/coins/{id}/ohlc` Get coin's OHLC
```{r, results='hide'}
```
---
#### Categories
- `/coins/categories/list` List all categories.
```{r, eval=FALSE}
coin_categories()
```
- `/coins/categories/list` List all categories with market data.
```{r, eval=FALSE}
coin_categories_data()
```
## Examples
#### Simple
`/simple/price` Get the current price of any cryptocurrencies in any other supported currencies that you need.
```{r, eval=FALSE}
price(ids = "bitcoin", vs_currencies = "usd")
```
`/simple/token_price/{id}` Get current price of tokens (using contract addresses) for a given platform in any other currency that you need.
```{r}
```
`/simple/supported_vs_currencies` Get list of supported_vs_currencies
```{r}
support_list <- supported_vs_currencies()
support_list[1:6]
```
---
#### Coins
- `/coins/list`
List all supported coins id, name and symbol.
```{r}
cl <- coins_list()
# Make as a data.frame
cl <- do.call(rbind, cl)
cl[1:3, ]
```
- `/coins/markets`
List all supported coins price, market cap, volume, and market related data.
```{r}
mkt <- markets(vs_currency = "usd", ids = "bitcoin")
mkt[[1]][c("id", "current_price")]
```
- `/coins/{id}`
Get current data (name, price, market, ... including exchange tickers) for a coin.
```{r}
cd <- coins_data(id = "bitcoin")
# See data types in the list
names(cd)
```
- `/coins/{id}/tickers`
Get coin tickers (paginated to 100 items).
This function returns a lot of information!
```{r, eval=FALSE}
ticker_dat <- coins_tickers(id="bitcoin")
```
---
#### Categories
- `/coins/categories/list`
List all categories
```{r}
cat_list <- coin_categories()
cat_list <- do.call(rbind, cat_list)
head(cat_list)
```
- `/coins/categories/list`
List all categories with market data
```{r}
cat_list <- coin_categories_data()
cat_list <- do.call(rbind, cat_list)
head(cat_list)
```
---
#### Examples
Retreive coin price history for a specific date
```{r}
btc_price_df <- get_coin_history(coin = "bitcoin",
date_POSIXlt = as.POSIXlt("2015-12-31"))
head(btc_price_df)
```