.NET SDK for Blockfrost.io API.
Getting started • Installation • Usage
To use this SDK, you first need login into to blockfrost.io create your project to retrive your API token.
The SDK is hosted on nuget.org, so you can directly import it using your favorite package manager.
$ dotnet new console -n blockfrost-client
$ cd blockfrost-client
$ dotnet add package Blockfrost.Api --version 0.0.4
🚧🚧🚧 Please report any issues you find here 👍
Before you install the command line tool, make sure the environment variables BFCLI_API_KEY
and BFCLI_NETWORK
exist.
$> $env:BFCLI_NETWORK
testnet
$> $env:BFCLI_API_KEY
yourawesomeapikeyforblockfrostio
$> pwd
{$SolutionDir}\src\Blockfrost.Cli
$> dotnet tool install bfcli --add-source nupkg --version 0.0.xyz
<!-- $> dotnet tool install bfcli --version 0.0.4 -->
Tool 'bfcli' (version '0.0.xyz') was successfully installed.
$> dotnet bfcli -v
bfcli v0.0.xyz
A .NET Cross Platform Tool / Console App for interacting with Blockfrost API.
USAGE: bfcli (OPTION | COMMAND)
Available options:
-v, --version Show the bfcli version
-h, --help Show this help text
Available commands:
health
$> dotnet bfcli health | ConvertFrom-Json
is_healthy
----------
True
Using the SDK is pretty straight-forward as you can see from the following example.
using Blockfrost.Api;
using Blockfrost.Api.Extensions;
using Microsoft.Extensions.DependencyInjection;
var network = "YOUR_PROJECT_NETWORK"; // testnet, mainnet
var apiKey = "YOUR_API_KEY";
var services = new ServiceCollection()
.AddBlockfrost(network, apiKey);
var service = services.BuildServiceProvider()
.GetRequiredService<IBlockfrostService>();
var health = await service.GetHealthAsync();
System.Console.WriteLine(health.IsHealthy);
$ dotnet run
True