boxkite

Integration

Go SDK

github.com/EvAlssment/boxkite/sdk-go talks to a hosted control-plane over HTTP. Mirrors sdk-python/sdk-js's BoxkiteClient method-for-method, adapted to Go idiom — (result, err) returns, request-struct params instead of keyword arguments, context.Context on every call.

Install

terminal
go get github.com/EvAlssment/boxkite/sdk-go

Quickstart

main.go
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/EvAlssment/boxkite/sdk-go"
)

func main() {
	client, err := boxkite.NewClient("https://your-control-plane.example.com", "bxk_live_...")
	if err != nil {
		log.Fatal(err)
	}

	ctx := context.Background()
	err = client.WithSandbox(ctx, boxkite.CreateSandboxRequest{Label: boxkite.Ptr("demo")}, func(sb *boxkite.Session) error {
		result, err := sb.Exec(ctx, "python3 -c 'print(1 + 1)'", nil)
		if err != nil {
			return err
		}
		fmt.Println(result.Stdout) // "2\n"
		return nil
	})
	// sandbox is destroyed automatically here, even if the callback returned an error
	if err != nil {
		log.Fatal(err)
	}
}

client.WithSandbox(ctx, req, fn) creates a sandbox, runs fn, and always destroys it on the way out — the Go equivalent of the Python/JS SDKs' context-manager pattern. Without it, own create/destroy yourself via client.CreateSandbox(ctx, req)/client.DestroySandbox(ctx, sessionID) — see Sandboxes for every field CreateSandboxRequest accepts.

Every capability, from this client

Error handling

Every non-2xx response returns *boxkite.APIError (with .StatusCode, .Code, .Messagefrom the control-plane's error envelope). A network-level failure returns *boxkite.ConnectionError, which unwraps to the underlying error.