-
Notifications
You must be signed in to change notification settings - Fork 3
/
blockchain_dot_com.R
105 lines (94 loc) · 2.84 KB
/
blockchain_dot_com.R
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
#' blockchain_dot_com_l2_order_book
#'
#' @param symbol the symbol for which to retrieve data
#'
#' @return returns a list containing a 'bids' and an 'asks' dataframe along with
#' the specified symbol
#' @export
#'
#' @examples
#' symbol <- 'BTC-USD'
#' l2_order_book <- blockchain_dot_com_l2_order_book(symbol)
#' l2_order_book$bids
#' l2_order_book$asks
blockchain_dot_com_l2_order_book <- function(symbol) {
res <- httr::GET(paste('https://api.blockchain.com/v3/exchange/l2/',
toupper(symbol), sep = ''))
data <- jsonlite::fromJSON(rawToChar(res$content))
return(data)
}
#' blockchain_dot_com_l3_order_book
#'
#' @param symbol the symbol for which to retrieve data
#'
#' @return returns a list containing a 'bids' and an 'asks' dataframe along with
#' the specified symbol
#' @export
#'
#' @examples
#' symbol <- 'BTC-USD'
#' l3_order_book <- blockchain_dot_com_l3_order_book(symbol)
#' l3_order_book$bids
#' l3_order_book$asks
blockchain_dot_com_l3_order_book <- function(symbol) {
res <- httr::GET(paste('https://api.blockchain.com/v3/exchange/l3/',
toupper(symbol), sep = ''))
data <- jsonlite::fromJSON(rawToChar(res$content))
return(data)
}
#' blockchain_dot_com_tickers
#'
#' @return returns a dataframe with price and volume data for all symbols
#' @export
#'
#' @examples
#' blockchain_dot_com_tickers()
blockchain_dot_com_tickers <- function() {
res <- httr::GET('https://api.blockchain.com/v3/exchange/tickers')
data <- jsonlite::fromJSON(rawToChar(res$content))
return(data)
}
#' blockchain_dot_com_ticker_symbol
#'
#' @param symbol the symbol for which to retrieve data
#'
#' @return returns a list with price and volume data for specified symbol
#' @export
#'
#' @examples
#' symbol <- 'BTC-USD'
#' blockchain_dot_com_ticker_symbol(symbol)
blockchain_dot_com_ticker_symbol <- function(symbol) {
res <- httr::GET(paste('https://api.blockchain.com/v3/exchange/tickers/',
toupper(symbol), sep = ''))
data <- jsonlite::fromJSON(rawToChar(res$content))
return(data)
}
#' blockchain_dot_com_symbols
#'
#' @return returns a list with various data for all symbols
#' @export
#'
#' @examples
#' blockchain_dot_com_symbols()
blockchain_dot_com_symbols <- function() {
res <- httr::GET('https://api.blockchain.com/v3/exchange/symbols')
data <- jsonlite::fromJSON(rawToChar(res$content))
return(data)
}
#' blockchain_dot_com_symbol
#'
#' @param symbol the symbol for which to retrieve data
#'
#' @return returns a list with various data for specified symbol
#' @export
#'
#' @examples
#' symbol <- 'BTC-USD'
#' blockchain_dot_com_symbol(symbol)
blockchain_dot_com_symbol <- function(symbol) {
res <- httr::GET(paste('https://api.blockchain.com/v3/exchange/symbols/',
toupper(symbol), sep = ''))
data <- jsonlite::fromJSON(rawToChar(res$content))
return(data)
}