Go SDK

Official Go client. Context-aware, idiomatic error returns, supports both REST and WebSocket.

Installation

go get github.com/sportapi/sportapi-go

Quick start

package main

import (
    "context"
    "fmt"
    "os"

    sportapi "github.com/sportapi/sportapi-go"
)

func main() {
    client := sportapi.NewClient(os.Getenv("SPORTAPI_KEY"))
    games, err := client.NBA.Scores.Live(context.Background())
    if err != nil { panic(err) }
    fmt.Println(games)
}

Configuration

client := sportapi.NewClient(key,
    sportapi.WithTimeout(10*time.Second),
    sportapi.WithMaxRetries(3),
    sportapi.WithAPIVersion("2025-09-01"),
)

Error handling

games, err := client.NBA.Scores.Live(ctx)
if err != nil {
    var rateErr *sportapi.RateLimitError
    if errors.As(err, &rateErr) {
        time.Sleep(rateErr.RetryAfter)
    }
}