Help Center/SDKs & Libraries

Go SDK quickstart

5 min read Updated February 10, 2026

Installation

bash
go get github.com/compliancegrid-ai/compliancegrid-go

Configuration

go
package main

import (
    "context"
    "fmt"
    "os"
    cg "github.com/compliancegrid-ai/compliancegrid-go"
)

func main() {
    client := cg.NewClient(
        cg.WithAPIKey(os.Getenv("CG_API_KEY")),
        cg.WithEnvironment(cg.Sandbox),
    )
}

Screening Example

go
result, err := client.Compliance.ScreenParties(context.Background(), &cg.ScreenRequest{
    Parties: []cg.Party{{
        Name:    "Acme Corp",
        Country: "US",
    }},
})
if err != nil {
    log.Fatal(err)
}
fmt.Println(result.OverallResult) // "CLEAR"

Context and Timeouts

All SDK methods accept a context.Context for cancellation and timeouts:

go
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result, err := client.HS.Search(ctx, "laptop")

Error Types

The Go SDK returns typed errors that you can inspect:

  • *cg.RateLimitError — Includes RetryAfter duration
  • *cg.AuthError — Authentication failures
  • *cg.ValidationError — Request validation failures
  • *cg.APIError — Generic API errors with status code and message

Was this article helpful?