C# SDK
Jaina.Client — .NET / Unity client targeting netstandard2.0.
Install
Available now via direct download.
Jaina.Clientis not on NuGet yet, but you can install the real build today:curl -O https://jaina.dev/downloads/nuget/Jaina.Client.0.2.0.nupkg dotnet add package Jaina.Client --version 0.2.0 --source .See all downloads (incl. the Unity DLL steps). The
dotnet add package Jaina.Clientcommand below is correct for when the package goes live on NuGet.
dotnet add package Jaina.Client
For Unity, download the DLL from NuGet and drop into Assets/Plugins/. Set the meta to Any Platform.
Quickstart
using Jaina.Client;
var client = new JainaClient(apiKey: System.Environment.GetEnvironmentVariable("JAINA_API_KEY"));
var projects = await client.Projects.ListAsync();
foreach (var p in projects.Items)
{
System.Console.WriteLine(p.Slug);
}
Typed records
public class Enemy
{
public string Name { get; set; }
public int Hp { get; set; }
public int Attack { get; set; }
public string Sprite { get; set; }
public string Rarity { get; set; }
}
var enemies = await client.Records.ListAsync<Enemy>("my-game", "enemy", new ListOptions {
Filter = new { hp = new { gte = 50 } }
});
foreach (var e in enemies.Items)
{
System.Console.WriteLine($"{e.Name} (HP {e.Hp})");
}
Generate the POCO with jaina codegen --lang csharp.
CancellationToken
Every async method accepts a CancellationToken:
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5));
var enemies = await client.Records.ListAsync<Enemy>("my-game", "enemy", cancellationToken: cts.Token);
IDisposable
JainaClient implements IDisposable. In typical app patterns, wrap with using or register as a singleton in DI.
using var client = new JainaClient(apiKey: "...");
Unity gotchas
Newtonsoft.Jsonis required (already in Unity 2020+). The SDK uses it for serialization.- Async/await in Unity requires UniTask or
Taskinterop. Both work. - WebGL builds: requests use UnityWebRequest under the hood. CORS applies — your Jaina API must allow your game's origin.
Error handling
try
{
await client.Records.CreateAsync("my-game", "enemy", new { name = "Goblin" });
}
catch (JainaApiException ex)
{
Console.WriteLine($"{ex.Status} {ex.Code}: {ex.Message}");
}