---
title: TypeScript
description: '@anyrow/sdk: every endpoint, typed, for Node.js, Bun, Deno, Cloudflare Workers and browsers.'
url: https://anyrow.ai/docs/sdks/typescript
canonical_url: https://anyrow.ai/docs/sdks/typescript
last_updated: '2026-10-16'
---

# TypeScript

`@anyrow/sdk` runs anywhere `fetch` does. Its types come from the API's OpenAPI document, so
every parameter, body and response is checked as you write the call.

## Install

```bash title="npm"
npm install @anyrow/sdk
```

```bash title="Bun"
bun add @anyrow/sdk
```

```bash title="pnpm"
pnpm add @anyrow/sdk
```

```bash title="Deno"
deno add jsr:@anyrow/sdk
```

## Create a client

```ts
import { AnyrowSDK } from "@anyrow/sdk"

const anyrow = new AnyrowSDK({
  baseURL: "https://api.anyrow.ai",
  headers: { Authorization: `ApiKey ${process.env.ANYROW_API_KEY}` },
  timeout: 30_000, // milliseconds; no timeout when unset
})
```

Create the client in server code: the key acts as its project. In Cloudflare Workers, create it
inside the request handler from `env`.

## Make a call

An operation's id is its method. Path parameters go in `params`, query parameters in `search`,
JSON bodies in `json` and form bodies (files) in `form`:

```ts
const { data, error, status } = await anyrow.row.list({
  params: { project_id: "proj_...", table_id: "tbl_..." },
  search: { limit: 50 },
})
```

## Errors

A call returns `{ data, error, status, response }`: `data` on success, `error` (the
[error body](/docs/errors)) otherwise. Check `error` before using `data`:

```ts
const { data: table, error } = await anyrow.table.get({
  params: { project_id: "proj_...", table_id: "tbl_..." },
})
if (error) {
  console.error(error.error_key, error.message)
} else {
  console.log(table.name)
}
```

To throw instead, set `throwOnError: true` on the client: a call then returns the data, and a
failure throws a `ClientError` subclass (`UnauthorizedError`, `ForbiddenError`,
`NotFoundError`, `RateLimitError` and one per status) with `status` and the parsed body in
`data`.

```ts
import { AnyrowSDK, ForbiddenError } from "@anyrow/sdk"

const anyrow = new AnyrowSDK({
  baseURL: "https://api.anyrow.ai",
  headers: { Authorization: `ApiKey ${process.env.ANYROW_API_KEY}` },
  throwOnError: true,
})

try {
  const table = await anyrow.table.get({ params: { project_id: "proj_...", table_id: "tbl_..." } })
} catch (error) {
  if (error instanceof ForbiddenError) console.error("The key lacks tables:read")
  throw error
}
```

## Read every row

```ts
const rows = []
let cursor: string | undefined
do {
  const { data, error } = await anyrow.row.list({
    params: { project_id: "proj_...", table_id: "tbl_..." },
    search: { limit: 100, cursor },
  })
  if (error) throw error
  rows.push(...data.rows)
  cursor = data.nextCursor ?? undefined
} while (cursor)
```

## Upload a file

Put a `Blob` in `form` and the SDK sends multipart form data:

```ts
import { readFile } from "node:fs/promises"

const { data: batch } = await anyrow.extract.table.once({
  params: { project_id: "proj_...", table_id: "tbl_..." },
  form: { file: new Blob([await readFile("./invoice.pdf")], { type: "application/pdf" }) },
})
```

In a browser, pass the `File` from an `<input type="file">` as it is.

## Stream an extraction

The `stream` calls return an async iterable of server-sent events:

```ts
for await (const event of anyrow.extract.table.stream({
  params: { project_id: "proj_...", table_id: "tbl_..." },
  form: { text: "Invoice 42 from Acme, total 120 EUR, due 2026-11-01" },
})) {
  console.log(event.event, event.data)
}
```

## Verify webhooks

Deliveries follow Standard Webhooks; verify them with the `standardwebhooks` package as the
[Webhooks guide](/docs/webhooks) shows.
