Skip to content

A light-weight API wrapper for the FlipsideCrypto query API

License

Notifications You must be signed in to change notification settings

PoolPirate/FlipsideCrypto.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlipsideCrypto.NET

A light-weight client for the FlipsideCrypto SQL query api. Now you have all the blockchain data on your fingertips with C#.

Supports

  • Creating / Cancelling Queries
  • Retrieving their status
  • Getting their result set & automatically mapping it to C# objects
  • Handling of common transient API errors by default

Usage

Installation

  • Install package from Nuget
  • Add it to your applications DI container.
services.AddFlipsideCrypto(API_KEY)

Creating a query

IFlipsideClient fs = //get from DI

var runId = fs.CreateQueryRunAsync("SELECT max(block_number) AS maxblockheight FROM ethereum.core.fact_blocks");

Getting query results

//Define class with property names matching query column names (case insensitive)
public class MaxBlockHeightQueryResult {
    public ulong MaxBlockHeight { get; init; }

    //Make sure to have a public parametereless constructor
    public MaxBlockHeightQueryResult() {}
}

MaxBlockHeightQueryResult[] results = await fs.GetQueryRunResults<MaxBlockHeightQueryResult>(YOUR_RUN_ID);

Combined create, wait, get result methods

Simple

//Creates a query, then uses Polly decorrelated jitter exponential backoff for retries till the query completes / fails / get cancelled.
//Fetches a single result page of given size
MaxBlockHeightQueryResult[] results = await fs.RunQueryAsync<MaxBlockHeightQueryResult>(
    "SELECT max(block_number) AS maxblockheight FROM ethereum.core.fact_blocks");

Batched

//Creates a query, then uses Polly decorrelated jitter exponential backoff for retries till the query completes / fails / get cancelled.
//Fetches the entire result set in batches
IAsyncEnumerable<MaxBlockHeightQueryResult[]> results = await fs.RunBatchedQueryAsync<MaxBlockHeightQueryResult>(
    "SELECT max(block_number) AS maxblockheight FROM ethereum.core.fact_blocks");

await foreach(MaxBlockHeightQueryResult[] batch in results) {

}

About

A light-weight API wrapper for the FlipsideCrypto query API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages