C# SDK
The official C# SDK for Crowd.Credit, compatible with .NET 8+.
Installation
dotnet add package CrowdCredit.SDK
Setup
using CrowdCredit.SDK;
var client = new CrowdCreditClient(new CrowdCreditOptions
{
ApiKey = Environment.GetEnvironmentVariable("CROWD_CREDIT_API_KEY")
});
Usage Examples
Account Management
// Get account details
var account = await client.Accounts.MeAsync();
Console.WriteLine($"Account: {account.WalletAddress}");
Credit
// Get credit line
var creditLine = await client.Credit.GetLineAsync();
Console.WriteLine($"Available: ${creditLine.Available}");
Console.WriteLine($"Health factor: {creditLine.HealthFactor}");
// Get graduation tier
var tier = await client.Credit.GetTierAsync();
Console.WriteLine($"Current tier: {tier.Name}");
Deposits
// List deposits
var deposits = await client.Deposits.ListAsync(new ListParams { Limit = 10 });
foreach (var deposit in deposits.Items)
{
Console.WriteLine($"Deposit: {deposit.Amount} {deposit.Token}");
}
Dependency Injection
// In Program.cs or Startup.cs
builder.Services.AddCrowdCredit(options =>
{
options.ApiKey = builder.Configuration["CrowdCredit:ApiKey"];
});
// In your service
public class MyService
{
private readonly ICrowdCreditClient _client;
public MyService(ICrowdCreditClient client)
{
_client = client;
}
}
Error Handling
try
{
await client.Credit.DrawAsync(new DrawRequest { Amount = "1000" });
}
catch (RateLimitException ex)
{
Console.WriteLine($"Rate limited. Retry after {ex.RetryAfter}s");
}
catch (CrowdCreditException ex)
{
Console.WriteLine($"API error: {ex.Code} - {ex.Message}");
}