Go SDK
Official Misar.Dev SDK for Go — build, deploy, and manage apps via api.misar.io/dev.
The official Misar.Dev client SDK for Go (module github.com/misar-ai/misardev-go, package misardev). This is an early v0.1.0 port implementing a subset of the reference SDK.
Installation
go get github.com/misar-ai/misardev-goimport "github.com/misar-ai/misardev-go/misardev"
Quick start
package main
import (
"context"
"fmt"
"github.com/misar-ai/misardev-go/misardev"
)
func main() {
client := misardev.New("your-api-key")
resp, err := client.ProjectsCreate(context.Background(), misardev.CreateProjectRequest{
Name: "my-app",
})
if err != nil {
panic(err)
}
fmt.Println(resp.ID)
}
Configuration
misardev.New(apiKey, ...opts) accepts functional options:
| Option | Description |
|---|---|
WithBaseURL(url string) | Override the base URL (default https://api.misar.io/dev) |
WithMaxRetries(n int) | Max retry attempts (default 3) |
WithHTTPClient(h *http.Client) | Supply a custom *http.Client (default timeout 30s) |
client := misardev.New(
"your-api-key",
misardev.WithMaxRetries(5),
)
Requests send Authorization: Bearer <apiKey>. Responses with status 429, 500, 502, 503, or 504 are retried with exponential backoff. Every call takes a context.Context for cancellation and deadlines.
Resources
| Method | Returns | Description |
|---|---|---|
ProjectsList(ctx) | *ProjectsListResponse | List projects |
ProjectsCreate(ctx, req) | *Project | Create a project (CreateProjectRequest) |
ApiKeysList(ctx) | *ApiKeysListResponse | List API keys |
UsageGet(ctx) | *UsageResponse | Get usage summary |
ChatComplete(ctx, req) | *ChatCompletionResponse | Run a chat completion (ChatCompletionRequest) |
This port covers listing/creating projects, listing API keys, usage, and chat completion. Deploy, templates, billing, RAG, and analytics are available in the TypeScript SDK.
Error handling
API responses return a *misardev.APIError (fields Status, Message, ErrorType). Transport failures return a *misardev.NetworkError (implements Unwrap() to expose the underlying error).
resp, err := client.ProjectsList(context.Background())
if err != nil {
var apiErr *misardev.APIError
var netErr *misardev.NetworkError
switch {
case errors.As(err, &apiErr):
fmt.Println(apiErr.Status, apiErr.ErrorType, apiErr.Message)
case errors.As(err, &netErr):
fmt.Println("network:", netErr.Message)
}
}