---
title: Go
description: 'github.com/anyrow/sdk-go: every endpoint with typed requests, responses and errors.'
url: https://anyrow.ai/docs/sdks/go
canonical_url: https://anyrow.ai/docs/sdks/go
last_updated: '2026-10-16'
---

# Go

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.

## Install

```bash
go get github.com/anyrow/sdk-go@latest
```

## Create a client

```go
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 call

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:

```go
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.

## Errors

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](/docs/errors) in `Body`:

```go
_, err := anyrow.Table.Get(ctx, "proj_...", "tbl_...", nil)

var forbidden *sdk.ForbiddenError
var apiErr sdk.APIError
switch {
case errors.As(err, &forbidden):
	fmt.Println("the key lacks tables:read")
case errors.As(err, &apiErr):
	fmt.Println(apiErr.Status(), err)
}
```

## Read every row

```go
var rows []map[string]json.RawMessage
opts := &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 document

```go
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 extraction

The `Stream` methods return an iterator of server-sent events:

```go
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 webhooks

Deliveries follow Standard Webhooks; verify them with
[`github.com/standard-webhooks/standard-webhooks/libraries/go`](https://github.com/standard-webhooks/standard-webhooks)
as the [Webhooks guide](/docs/webhooks) describes.
