C# SDK
Official Misar.Dev SDK for C# — build, deploy, and manage apps via api.misar.io/dev.
The official Misar.Dev client SDK for C#. Async, with built-in retries and typed exceptions. Targets .NET 8.
Installation
dotnet add package MisarDevRequires .NET 8+.
Quick start
Construct a MisarDevClient with your API key (must start with mdk_) and point it at the Misar.Dev API:
using MisarDev;
using var client = new MisarDevClient(
apiKey: "mdk_your_api_key",
baseUrl: "https://api.misar.io/dev");
// List your projects
JsonElement projects = await client.ProjectsListAsync();
Console.WriteLine(projects);
MisarDevClient is IDisposable — dispose it (or use using) to release the internally-created HttpClient.
Configuration
| Parameter | Default | Description |
|---|---|---|
apiKey | — | Required. Must start with mdk_ or the constructor throws ArgumentException. |
baseUrl | https://misar.dev/api | Set to https://api.misar.io/dev. |
maxRetries | 3 | Retry attempts for retryable status codes (429, 500, 502, 503, 504) with exponential backoff. |
httpClient | null | Optional pre-configured HttpClient (not disposed by the client when supplied). |
Every request sends Authorization: Bearer <apiKey> and accepts application/json. Responses are returned as System.Text.Json.JsonElement.
Resources
This early v1.0.0 port implements the following methods. Each returns Task<JsonElement>.
| Method | HTTP | Description |
|---|---|---|
ProjectsListAsync() | GET /projects | List projects. |
ProjectsCreateAsync(object parameters) | POST /projects | Create a project. |
TemplatesListAsync() | GET /templates | List templates. |
ApiKeysListAsync() | GET /api-keys | List API keys. |
ChatCompleteAsync(object parameters) | POST /chat | Send a chat completion request. |
UsageGetAsync() | GET /usage | Retrieve usage data. |
// Create a project
JsonElement project = await client.ProjectsCreateAsync(new {
name = "my-app",
template = "nextjs"
});
// Chat completion
JsonElement reply = await client.ChatCompleteAsync(new {
messages = new[] {
new { role = "user", content = "Hello" }
}
});
This is an early v1.0.0 port and intentionally exposes a subset of the full API surface (projects, templates, api-keys, chat, usage). Other resources available in the TypeScript SDK are not yet ported.
Error handling
Non-success responses throw a MisarDevException, specialized by status:
| Exception | Status | Notes |
|---|---|---|
AuthException | 401 | Invalid or missing API key. |
RateLimitException | 429 | Too many requests (retried first). |
ServerException | >= 500 | Upstream/server error (5xx retried first). |
MisarDevException | other | Base type for all other non-2xx responses. |
try
{
var projects = await client.ProjectsListAsync();
}
catch (AuthException e)
{
Console.WriteLine($"Auth failed: {e.Body}");
}
catch (RateLimitException e)
{
Console.WriteLine($"Rate limited: {e.Body}");
}
catch (MisarDevException e)
{
Console.WriteLine($"API error {e.StatusCode}: {e.Body}");
}
Retryable status codes (429, 500, 502, 503, 504) are retried automatically up to maxRetries before the exception is thrown.