A light-weight client for the FlipsideCrypto SQL query api. Now you have all the blockchain data on your fingertips with C#.
- Creating / Cancelling Queries
- Retrieving their status
- Getting their result set & automatically mapping it to C# objects
- Handling of common transient API errors by default
- Install package from Nuget
- Add it to your applications DI container.
services.AddFlipsideCrypto(API_KEY)
IFlipsideClient fs = //get from DI
var runId = fs.CreateQueryRunAsync("SELECT max(block_number) AS maxblockheight FROM ethereum.core.fact_blocks");
//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);
//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");
//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) {
}