[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
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:
Item | Definition |
---|---|
Description | Grabs up to |
Usage | auto_paginate_query(query, api_key) |
query | Flipside Crypto Snowflake SQL compatible query as a string. |
api_key | Flipside Crypto ShroomDK API Key |
maxrows | Flipside Crypto ShroomDK maximum rows in query, default 1,000,000 |
value | data frame of up to 1M rows,
see ? |
For detailed examples using exclusively auto_paginate_query() see the Examples.
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:
Item | Definition |
---|---|
Description | Uses Flipside ShroomDK to create a Query Token to access Flipside Crypto data. The query token is cached up to ttl minutes allowing for pagination and multiple requests before expending more daily request uses. |
Usage | create_query_token(query, api_key, ttl = 10, cache = TRUE) |
query | Flipside Crypto Snowflake SQL compatible query as a string. |
api_key | Flipside Crypto ShroomDK API Key |
ttl | time (in minutes) to keep query in cache. |
cache | Use cached results; set as FALSE to re-execute. |
Value | list of |
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:
Item | Definition |
---|---|
Description | Uses Flipside ShroomDK to access a Query Token. Query tokens are cached up to 'ttl' minutes for each 'query'. This function is for pagination and multiple requests while reducing your use of your daily rate limit. Note: To reduce payload it returns a list of outputs (separating column names from rows). |
Usage | get_query_from_token(query_token, api_key, page_number = 1, page_size = 1e+05) |
query_token | token from 'create_query_token()' |
api_key | Flipside Crypto ShroomDK API Key |
page_number | Query tokens are cached and 100k rows max. Get up to 1M rows by going through pages. |
page_size | Default 100,000. Paginate via page_number. |
Value | returns a request of length 8: |
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:
Item | Definition |
---|---|
Description | Cleans Query to be in Data Frame format |
Usage | clean_query(request, try_simplify = TRUE) |
| The request output from |
try_simplify | because requests can return JSON and/or may not have the same length across values, they may not be data frame compliant (all columns having the same number of rows). A key example would be TX_JSON in EVM FACT_TRANSACTION tables which include 50+ extra details from transaction logs. But other examples like |
Value | Always returns a data frame. If 'try_simplify' is |
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).
Last updated