[LEGACY] R

The R programming language is a great fit for analysis of flipsidecrypto data!

The R SDK is currently undergoing an upgrade to be compatible with V2 of Flipside's API. Until that update rolls out, the R SDK can only be used by legacy ShroomDK users.

For Legacy ShroomDK users: once the upgrade is complete you will be able to seamlessly upgrade to the latest version of the SDK without any changes to your existing code.

To skip the walkthrough and go straight to dedicated API Documentation, click here.

How to Install

# available on CRAN
install.packages("shroomDK")
library(shroomDK)

# Latest developments available on Github
library(devtools) # install if you haven't already
devtools::install_github(repo = 'FlipsideCrypto/sdk', subdir = 'r/shroomDK')
library(shroomDK)

Auto Paginate Query

auto_paginate_query() The easiest way to use shroomDK is to simply auto paginate a query to return (up to) 1 Million rows in 1 function call. This function will attempt to report useful errors and warnings; but if results are not as expected, follow the traditional create_query_token() %>% get_query_from_token() %>% clean_query() pipeline. Documentation can be viewed within RStudio with ?auto_paginate_query for new packages you may need to restart R to get to the documentation. It is summarized here:

For detailed examples using exclusively auto_paginate_query() see the Examples.

# example
auto_paginate_query(query = "SELECT * FROM ethereum.core.fact_transactions LIMIT 1", 
                    api_key = readLines("api_key.txt")
                    )

Core Functions

create_query_token()

Documentation can be viewed within RStudio with ?create_query_token for new packages you may need to restart R to get to the documentation. It is summarized here:

# example
create_query_token(
query = "SELECT * FROM ethereum.core.fact_transactions LIMIT 1",
api_key = readLines("api_key.txt"), # gitignore your api_key! don't share!
ttl = 15,
cache = TRUE)

get_query_from_token()

Documentation can be viewed within RStudio with ?get_query_from_token for new packages you may need to restart R to get to the documentation. It is summarized here:

# example
query = create_query_token("SELECT * FROM ETHEREUM.CORE.FACT_TRANSACTIONS LIMIT 10000", api_key) #gitignore your API key!
get_query_from_token(query$token, api_key, 1, 10000)

clean_query()

Documentation can be viewed within RStudio with ?clean_query for new packages you may need to restart R to get to the documentation. It is summarized here:

Note: The vast majority (95%+) of queries will return a simple data frame with the classes coerced intelligently (e.g., Block_Number being numeric). But check the warnings and check your column classes, if the class is a list then try_simplify failed (i.e., not all columns have the same number of rows when coerced).

#example
query = create_query_token("SELECT * FROM ETHEREUM.CORE.FACT_TRANSACTIONS LIMIT 10000", api_key)
request = get_query_from_token(query$token, api_key, 1, 10000)
clean_query(request, try_simplify = FALSE) # returns data frame of lists()

Last updated