/blockfrost-dotnet

.NET, C# and PowerShell SDK for Blockfrost.io API

Primary LanguageC#Apache License 2.0Apache-2.0

.NET

blockfrost-dotnet


.NET SDK for Blockfrost.io API.

Getting startedInstallationUsage


Getting started

To use this SDK, you first need login into to blockfrost.io create your project to retrive your API token.


Installation

Add package

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 👍

Command line tool

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

Install the command line tool

$> 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

Usage

Using the SDK is pretty straight-forward as you can see from the following example.

Cardano

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