README.md

stellaRbase - an R library for Stellar

CRAN
Status

Disclaimer

This is not a project maintained by or officially endorsed by the Stellar Development Foundation. However, it is now officially on CRAN! To install directly from CRAN:

install.packages("stellaRbase")

To install the development version directly from this Github repo, install the devtools library and do the following:

devtools::install_github("froocpu/stellaRbase") # install.packages("devtools")

Or to download the development version

Why?

Community-developed SDKs exist for Python, C#, Java, Go and other languages of choice. This R library acts as an interface to Stellar's Horizon API and hopes to open up the Stellar network to avid R users interested in:

Using stellaRbase

The library acts as a wrapper and allows you to call the full range of Horizon API endpoints and resources from your R project. All requests currently do not require you to have any special permissions to use the network, and there is no need to register an application beforehand.

You can use stellaRbase to:

Contributing

Please use the Gitflow Workflow when contributing:

Data

Data is delivered as a structured tabular format (a data.table) or as a semi-structured list for you to work with the complete set of values. See the examples below for more information.

TODO

In progress

Needs improving/further testing

Known issues

Examples and walkthrough

Loading the library

To use the libary in your R code (once you've successfully downloaded it):

library(stellaRbase)

Making requests

You can use the data.table parameter on a number of functions to toggle whether you received a list object or a tabular format. data.table = TRUE will return a data.table for you to work with. FALSE will return a list, parsed using the fromJSON function.

For example, you can get Effects events as a table:

getEffects(limit = 5)[, c(1,2,4,5,6)]
#                               id  paging_token             type type_i starting_balance
#1: 0000000012884905985-0000000001 12884905985-1  account_created      0       20.0000000
#2: 0000000012884905985-0000000002 12884905985-2  account_debited      3               NA
#3: 0000000012884905985-0000000003 12884905985-3   signer_created     10               NA
#4: 0000000012884905986-0000000001 12884905986-1 account_credited      2               NA
#5: 0000000012884905986-0000000002 12884905986-2  account_debited      3               NA

Or as a list:

getEffects(limit = 1, data.table = FALSE)[['_embedded']][['records']]

#[[1]]$id
#[1] "0000000012884905985-0000000001"

#[[1]]$paging_token
#[1] "12884905985-1"

#[[1]]$account
#[1] "GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB"

#[[1]]$type
#[1] "account_created"

#[[1]]$type_i
#[1] 0

#[[1]]$starting_balance
#[1] "20.0000000"

Transactions

Get the latest 10 transactions:

getTransactions(limit = 10)

Or get details about a specific transaction:

hash = "b957fd83d5377402ee995d1c3ff4834357f48cbe9a6d42477baad52f1351c155"
getTransactionDetail(hash)

Or pull all of the transactions connected to an address:

address = "GCO2IP3MJNUOKS4PUDI4C7LGGMQDJGXG3COYX3WSB4HHNAHKYV5YL3VC"
getTransactions_Account(address)

Accounts

Get information about a particular account on the ledger:

getAccount(address)

Ledgers

Get the latest n ledgers in a single, one-off call:

getLedgers(limit = 10, order = "desc")

Or you can get the transactions appended to a specific ledger:

getTransactions_Ledger(17008514)

Trades and trade aggregations

Get the latest trades:

getTrades()

Or trade aggregations, direct from the API:

start_time <- "1512689100000"
end_time <- "1512775500000"
resolution <- "300000"

base_asset_type <- "native"

counter_asset_type <- "credit_alphanum4"
counter_asset_code <- "BTC"
counter_asset_issuer <- "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH"

getTradeAggregations(start_time, end_time, resolution,
                     base_asset_type = base_asset_type,
                     counter_asset_type = counter_asset_type,
                     counter_asset_code = counter_asset_code,
                     counter_asset_issuer = counter_asset_issuer,
                     data.table = TRUE)

Price ticker

Get the thing that everyone cares about the most - the price. The price() function currency returns the current price from Binance in USD, BTC, ETH or BNB:

price("USD")

#       USD 
# 0.4467322

Add live = TRUE to make continuous requests. It will wait a second between each successful requests to slow down hitting the rest API call limits.



froocpu/stellaR documentation built on May 17, 2019, 7:05 p.m.