Go
github.com/anyrow/sdk-go: every endpoint with typed requests, responses and errors.
The Go SDK has a typed method, request and response for every endpoint, and one error type per status. It needs Go 1.24 or later.
InstallLink to section
go get github.com/anyrow/sdk-go@latestCreate a clientLink to section
import ( "os" "time" sdk "github.com/anyrow/sdk-go")anyrow := sdk.NewClient(sdk.Config{ BaseURL: "https://api.anyrow.ai", BearerToken: os.Getenv("ANYROW_API_KEY"), Timeout: 30 * time.Second,})The client sends the key as Authorization: ApiKey <key>. Timeout defaults to 30 seconds;
a negative value turns it off.
Make a callLink to section
An operation's id is its method in Pascal case. Every method takes a context.Context, the
path parameters in path order, the body when there is one, and an options struct (or nil)
named after the method, which holds the query parameters:
limit := int64(50)page, err := anyrow.Row.List(ctx, "proj_...", "tbl_...", &sdk.RowListOpts{Limit: &limit})if err != nil { return err}for _, row := range page.Rows { fmt.Println(row)}Request types are named after the operation's body (sdk.CreateProjectsTableRequest for
table.create); a body with free-form columns, like a row, is a map of JSON values.
ErrorsLink to section
A failed call returns an sdk.APIError with the status; each status has its own type
(*sdk.ForbiddenError, *sdk.NotFoundError, *sdk.RateLimitError and the rest) carrying
Message and the raw error body in Body:
_, err := anyrow.Table.Get(ctx, "proj_...", "tbl_...", nil)var forbidden *sdk.ForbiddenErrorvar apiErr sdk.APIErrorswitch {case errors.As(err, &forbidden): fmt.Println("the key lacks tables:read")case errors.As(err, &apiErr): fmt.Println(apiErr.Status(), err)}Read every rowLink to section
var rows []map[string]json.RawMessageopts := &sdk.RowListOpts{}for { page, err := anyrow.Row.List(ctx, "proj_...", "tbl_...", opts) if err != nil { return err } rows = append(rows, page.Rows...) if page.NextCursor == nil { break } opts.Cursor = page.NextCursor}Extract a documentLink to section
invoice, err := os.ReadFile("./invoice.txt")if err != nil { return err}batch, err := anyrow.Extract.Table.Once(ctx, "proj_...", "tbl_...", url.Values{ "text": {string(invoice)},}, nil)Stream an extractionLink to section
The Stream methods return an iterator of server-sent events:
form := url.Values{"text": {"Invoice 42 from Acme"}}for event, err := range anyrow.Extract.Table.Stream(ctx, "proj_...", "tbl_...", form, nil) { if err != nil { return err } fmt.Println(event.Event, event.Data)}Verify webhooksLink to section
Deliveries follow Standard Webhooks; verify them with
github.com/standard-webhooks/standard-webhooks/libraries/go (opens in a new tab)
as the Webhooks guide describes.