# Installation

Install the NuGet package and register services.

URL: https://docs.shiwake.app/docs/sdk/installation



Requirements [#requirements]

* **.NET 8.0** or later
* An Shiwake API key: see [Authentication](/docs/api/authentication)
  and the platform [rotate-api-key](/docs/api/tenants#rotate-api-key)
  endpoint

Install the package [#install-the-package]

```bash
dotnet add package LedgerCore.Sdk
```

Or in a `.csproj`:

```xml
<PackageReference Include="LedgerCore.Sdk" Version="1.0.0" />
```

The package brings in `Microsoft.Extensions.DependencyInjection.Abstractions`,
`Microsoft.Extensions.Http`, and `Microsoft.Extensions.Options` as its only
runtime dependencies.

Register the core client [#register-the-core-client]

In `Program.cs`:

```csharp
using LedgerCore.Sdk;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddLedgerCoreSdk(options =>
{
    options.BaseUrl = "https://api.shiwake.example.com";
    options.ApiKey  = builder.Configuration["LedgerCore:ApiKey"]!;
});
```

This registers `ILedgerCoreClient` as a transient service backed by a
managed `HttpClient` via `IHttpClientFactory`. Inject it anywhere:

```csharp
public class DepositHandler(ILedgerCoreClient ledger)
{
    public async Task HandleAsync(/* ... */) { /* ... */ }
}
```

Register the banking clients [#register-the-banking-clients]

Two different banking clients ship with the SDK: register whichever you
need (or both).

Banking API client (full) [#banking-api-client-full]

For production banking workloads: wallets, fee schedules, hold/capture
withdrawals, limits, suspense, statements, audit. See
[`IBankingApiClient`](/docs/sdk/banking-api).

```csharp
builder.Services.AddLedgerCoreSdk(options => { /* ... */ });
builder.Services.AddLedgerCoreBankingApi();
```

`IBankingApiClient` is then injectable:

```csharp
public class WalletController(IBankingApiClient banking) : ControllerBase
{
    // ...
}
```

Banking client (simple) [#banking-client-simple]

A minimal wrapper that posts journal entries directly, no wallets, no
fees. Right for very small products or quick prototypes. See
[`IBankingClient`](/docs/sdk/banking).

```csharp
builder.Services.AddLedgerCoreSdk(options => { /* ... */ });
builder.Services.AddLedgerCoreBanking(); // uses PlatformFloatAccountCode = "PLATFORM-FLOAT"
```

Or override the defaults:

```csharp
builder.Services.AddLedgerCoreBanking(options =>
{
    options.PlatformFloatAccountCode = "MAIN-FLOAT";
    options.ClientAccountCodePrefix  = "WALLET-";
});
```

Binding from appsettings.json [#binding-from-appsettingsjson]

There is an overload that binds directly from `IConfiguration`:

```json
{
  "LedgerCore": {
    "BaseUrl": "https://api.shiwake.example.com",
    "ApiKey": "sk_live_...",
    "ApiVersion": "1",
    "TimeoutSeconds": 30
  }
}
```

```csharp
builder.Services.AddLedgerCoreSdk(builder.Configuration);
builder.Services.AddLedgerCoreBankingApi();
```

The default section name is `"LedgerCore"`. Pass a second argument to
override it.

<Callout type="warn">
  Do not commit API keys to `appsettings.json`. Use user secrets in
  development and environment variables / a key vault in production.
</Callout>

Verifying the install [#verifying-the-install]

A quick smoke test. List accounts in your tenant:

```csharp
var ledger = app.Services.GetRequiredService<ILedgerCoreClient>();
var page = await ledger.ListAccountsAsync(size: 5);
Console.WriteLine($"Got {page.Accounts.Count} accounts");
```

If that runs without throwing, you're wired up correctly. If you see a
`LedgerCoreException` with status `401`, the API key is wrong. `403` means
the tenant is disabled. See [Error handling](/docs/sdk/error-handling).
