SDKs
Go SDK
The official Go SDK for the Anagrama API. Idiomatic Go with context support, functional options, and structured errors.
Configuration
Create a client with functional options. The SDK automatically reads ANAGRAMA_API_KEY from the environment.
Go
package main
import (
"context"
"fmt"
anagramasdk "github.com/AnagramaGames/anagrama-go"
"github.com/AnagramaGames/anagrama-go/option"
)
func main() {
// Reads ANAGRAMA_API_KEY from env
client := anagramasdk.NewClient()
// Or explicit key
client = anagramasdk.NewClient(
option.WithAPIKey("ak_your_key_here"),
)
}First request
Go
client := anagramasdk.NewClient()
// Fetch 3 random words between 5-8 letters
response, err := client.Words.Random(
context.Background(),
anagramasdk.WordRandomParams{
Count: anagramasdk.Int(3),
MinLength: anagramasdk.Int(5),
MaxLength: anagramasdk.Int(8),
},
)
if err != nil {
log.Fatal(err)
}
fmt.Println(response.Words)
// => [tiger flame grove]
fmt.Println(response.Count)
// => 3Parameters: Count (1–10, default 1), MinLength (3–15, default 3), MaxLength (3–15, default 15). All optional — wrap with anagramasdk.Int() or anagramasdk.String().
Common patterns
Daily word
Go
response, err := client.Words.Daily(
context.Background(),
anagramasdk.WordDailyParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Today's word (%s): %s\n", response.Date, response.Word)
// => Today's word (2026-02-15): flameValidate a word
Go
result, err := client.Words.Validate(
context.Background(),
anagramasdk.WordValidateParams{
Word: "flame",
},
)
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Valid)
// => trueDictionary lookup
Go
entry, err := client.Dictionary.Lookup(
context.Background(),
"flame",
anagramasdk.DictionaryLookupParams{},
)
if err != nil {
log.Fatal(err)
}
fmt.Println(entry.Word, len(entry.Results))Fetch a wordset
Go
wordset, err := client.Wordsets.Get(
context.Background(),
"ws_Ab3xK9mQ",
anagramasdk.WordsetGetParams{
Random: anagramasdk.String("true"),
Limit: anagramasdk.Int(5),
Scramble: anagramasdk.String("true"),
},
)
if err != nil {
log.Fatal(err)
}
fmt.Println(wordset.Name, wordset.WordCount)
// => Animals 5Error handling
API errors are returned as structured error types. Use errors.As to inspect the status code and response:
Go
import (
"errors"
"github.com/AnagramaGames/anagrama-go/internal/apierror"
)
response, err := client.Words.Random(
context.Background(),
anagramasdk.WordRandomParams{
Count: anagramasdk.Int(3),
},
)
var apierr *apierror.Error
if errors.As(err, &apierr) {
fmt.Println(apierr.StatusCode) // 429, 401, 400, etc.
fmt.Println(apierr.Message)
}Context and timeouts
All methods accept a context.Context as the first argument for cancellation and timeouts:
Go
ctx, cancel := context.WithTimeout(
context.Background(), 5*time.Second,
)
defer cancel()
response, err := client.Words.Random(
ctx,
anagramasdk.WordRandomParams{
Count: anagramasdk.Int(3),
},
)
if err != nil {
// Could be context.DeadlineExceeded or API error
log.Fatal(err)
}