Skip to main content
The Go SDK is consumed via its module path github.com/teambattles/sdk-go. Go has no central package registry - the module is fetched directly from its VCS path at a version tag. It is generated from the OpenAPI spec with Microsoft Kiota and regenerates on every API change.

Install

go get github.com/teambattles/sdk-go

Authenticated first call

import (
    "context"
    "fmt"
    "log"
    "os"

    sdk "github.com/teambattles/sdk-go"
    "github.com/teambattles/sdk-go/models"
)

client, err := sdk.CreateTeamBattlesClient(os.Getenv("TEAMBATTLES_API_KEY"))
if err != nil {
    log.Fatal(err)
}

// List the authenticated user's matches (requires matches.user_matches: read)
body := models.NewMatchesRequestBody()
numItems := int32(25)
body.SetNumItems(&numItems)
result, err := client.User().Matches().Post(context.Background(), body, nil)
if err != nil {
    log.Fatal(err)
}
for _, match := range result.GetPage() {
    fmt.Println(*match.GetId(), match.GetStatus())
}

Authentication

The factory wires an Authorization: Bearer tb_<your-key> header on every request. Create keys at Settings > Developer and review scopes in the authentication guide. Treat the error machine code in error responses - not the details message - as the stable programmatic contract.