---
title: "AEO API TypeScript SDK: Install and Setup | AEO API"
description: "Set up the server-side TypeScript client, handle API errors and find the method for your AEO workflow."
url: "https://aeoapi.dev/docs/sdks/typescript"
canonical: "https://aeoapi.dev/docs/sdks/typescript"
last_updated: "2026-11-30"
---

# AEO API TypeScript SDK

Use `@aeoapi/aeo-sdk` on a server running Node.js 20 or later. The client has a method for each v2 operation and helpers for reading lists and waiting for runs.

## Install the package

Use Git and npm to clone the [Node.js SDK repository](https://github.com/aeo-api/aeoapi-nodejs-sdk) and build the package. `npm pack` runs the build and prints the archive filename.

```
git clone https://github.com/aeo-api/aeoapi-nodejs-sdk.git
cd aeoapi-nodejs-sdk
npm ci
npm pack
```

From your application directory, install the archive. Substitute the path and filename from your build.

```
npm install /path/to/aeoapi-nodejs-sdk/aeoapi-aeo-sdk-0.3.0.tgz
```

## Set up the client

Set `AEO_API_KEY` on your server. To check your connection, use a key with `account:read` and request the account overview. Set `baseUrl` to the API origin without `/v2`.

```
import { AeoClient } from "@aeoapi/aeo-sdk";

const apiKey = process.env.AEO_API_KEY;
if (!apiKey) throw new Error("Set AEO_API_KEY on your server.");
const client = new AeoClient(apiKey, { baseUrl: "https://api.aeoapi.dev" });

const account = await client.v2GetAccount();
console.log(account.status, account.body);
```

HTTP 200 returns your plan and limits in `body.data`. Endpoint methods return `ApiResponse<unknown>`. Check or narrow the body type before accessing its fields in TypeScript.

## Read the response

- `status` is the HTTP status. `body` holds parsed JSON, a CSV string for CSV exports, or `null` for an empty body.
- `headers` contains the HTTP headers. `requestId` identifies the request and `etag` holds the revision header when available.
- `usageUnits` is the number from `X-Usage-Units`, or `null` if the header is missing or contains anything other than digits.

## Handle errors

For `AeoApiError`, read `status` and `code` to decide what to do next. Validation errors can include `fieldErrors`. Keep `requestId` if you contact support.

If the connection fails or the client cannot finish reading a successful response, it throws `AeoTransportError` after any allowed retries. If a successful response contains invalid JSON, the client throws `SyntaxError` without retrying.

```
import { AeoApiError, AeoTransportError } from "@aeoapi/aeo-sdk";
import { AeoClient } from "@aeoapi/aeo-sdk";

const apiKey = process.env.AEO_API_KEY;
if (!apiKey) throw new Error("Set AEO_API_KEY on your server.");
const client = new AeoClient(apiKey, { baseUrl: "https://api.aeoapi.dev" });

try {
  const account = await client.v2GetAccount();
  console.log(account.body);
} catch (error) {
  if (error instanceof AeoApiError) {
    console.error(error.status, error.code, error.requestId, error.fieldErrors);
  } else if (error instanceof AeoTransportError) {
    console.error(error.message);
  } else if (error instanceof SyntaxError) {
    console.error("The response contained invalid JSON.");
  } else {
    throw error;
  }
}
```

See the [API error codes](https://aeoapi.dev/docs/errors) for recovery steps. Invalid client options can throw a JavaScript `Error` or `TypeError` before the request is sent.

## Retries and request keys

The SDK retries GET requests and writes that require `Idempotency-Key`. It allows two retries by default after a network failure, HTTP 429, or HTTP 503 when the error is marked retryable. A write that accepts the header as optional does not qualify for automatic retries.

For a required key, the SDK generates one per call and sends the same value on every retry. To retry a write from your own job, persist the body and pass the same `options.idempotencyKey` on the next call. Keys must contain 8 to 128 visible ASCII characters.

Pass `retry` in the constructor to change the policy. The default randomized backoff starts with a 500 ms upper bound and caps at 8000 ms. A numeric `Retry-After` of up to 60 seconds takes precedence. A longer delay returns the error to your application.

## Set a deadline

Requests have no default timeout. Pass an `AbortSignal` to cancel an active request at your deadline. In `waitForRun`, `timeoutMs` controls whether another wait can start. An active request can run past that deadline. If you abort during a wait, the next request receives the aborted signal when the wait ends.

```
import { AeoClient } from "@aeoapi/aeo-sdk";

const apiKey = process.env.AEO_API_KEY;
if (!apiKey) throw new Error("Set AEO_API_KEY on your server.");
const client = new AeoClient(apiKey, { baseUrl: "https://api.aeoapi.dev" });

const controller = new AbortController();
const deadline = setTimeout(() => controller.abort(), 10_000);
try {
  const account = await client.v2GetAccount({ signal: controller.signal });
  console.log(account.body);
} finally {
  clearTimeout(deadline);
}
```

## Read more than one page

Use [paginate](https://aeoapi.dev/docs/sdks/typescript/paginate) for whole pages or [iterItems](https://aeoapi.dev/docs/sdks/typescript/iterItems) for individual records when a response returns `meta.next_cursor`. For the draft list, pass `data.next_offset` as `offset` instead.

## Wait for a run

Pass a qualified run ID or poll URL to [`waitForRun`](https://aeoapi.dev/docs/sdks/typescript/waitForRun). For Brave submissions, it returns at `submitted` or `failed`. To check the status yourself, follow the [Brave polling example](https://aeoapi.dev/docs/guides/submit-to-brave#3-check-the-outcome).

## Method reference

Some features share a method. For example, a site audit and a collection run both start with `v2PostRuns`. The `workflow` field selects the work.

### Client setup

- [`AeoClient`](https://aeoapi.dev/docs/sdks/typescript/AeoClient)
- [`baseUrl`](https://aeoapi.dev/docs/sdks/typescript/baseUrl)
- [`toJSON`](https://aeoapi.dev/docs/sdks/typescript/toJSON)
- [`ifMatchHeader`](https://aeoapi.dev/docs/sdks/typescript/ifMatchHeader)

### Pagination and run polling

- [`paginate`](https://aeoapi.dev/docs/sdks/typescript/paginate)
- [`iterItems`](https://aeoapi.dev/docs/sdks/typescript/iterItems)
- [`itemsOf`](https://aeoapi.dev/docs/sdks/typescript/itemsOf)
- [`waitForRun`](https://aeoapi.dev/docs/sdks/typescript/waitForRun)

### Account and usage

- [`v2GetAccount`](https://aeoapi.dev/docs/sdks/typescript/v2GetAccount)
- [`v2PatchAccount`](https://aeoapi.dev/docs/sdks/typescript/v2PatchAccount)

### Brands, locations and connections

- [`v2GetBrands`](https://aeoapi.dev/docs/sdks/typescript/v2GetBrands)
- [`v2PostBrands`](https://aeoapi.dev/docs/sdks/typescript/v2PostBrands)
- [`v2GetBrandsBrandId`](https://aeoapi.dev/docs/sdks/typescript/v2GetBrandsBrandId)
- [`v2PatchBrandsBrandId`](https://aeoapi.dev/docs/sdks/typescript/v2PatchBrandsBrandId)

### Prompts and topics

- [`v2GetPrompts`](https://aeoapi.dev/docs/sdks/typescript/v2GetPrompts)
- [`v2PostPrompts`](https://aeoapi.dev/docs/sdks/typescript/v2PostPrompts)
- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2PatchPrompts`](https://aeoapi.dev/docs/sdks/typescript/v2PatchPrompts)

### AI answer collection and runs

- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRuns`](https://aeoapi.dev/docs/sdks/typescript/v2GetRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)
- [`v2DeleteRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2DeleteRunsRunId)

### Site audits and page checks

- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)
- [`v2DeleteRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2DeleteRunsRunId)
- [`v2GetAnalyticsDataset`](https://aeoapi.dev/docs/sdks/typescript/v2GetAnalyticsDataset)

### Citations

- [`v2GetAnalyticsDataset`](https://aeoapi.dev/docs/sdks/typescript/v2GetAnalyticsDataset)
- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)

### Answer accuracy

- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)
- [`v2GetAnalyticsDataset`](https://aeoapi.dev/docs/sdks/typescript/v2GetAnalyticsDataset)

### Retrieval simulator and content testing

- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)
- [`v2PostPassagesSearch`](https://aeoapi.dev/docs/sdks/typescript/v2PostPassagesSearch)

### Recommendations and visibility analyst

- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)
- [`v2GetRecommendations`](https://aeoapi.dev/docs/sdks/typescript/v2GetRecommendations)
- [`v2PatchRecommendations`](https://aeoapi.dev/docs/sdks/typescript/v2PatchRecommendations)

### Content drafts and editorial generation

- [`v2GetBrandsBrandId`](https://aeoapi.dev/docs/sdks/typescript/v2GetBrandsBrandId)
- [`v2PatchBrandsBrandId`](https://aeoapi.dev/docs/sdks/typescript/v2PatchBrandsBrandId)
- [`v2PutBrandsBrandIdDraftsDraftId`](https://aeoapi.dev/docs/sdks/typescript/v2PutBrandsBrandIdDraftsDraftId)
- [`v2GetBrandsBrandIdDrafts`](https://aeoapi.dev/docs/sdks/typescript/v2GetBrandsBrandIdDrafts)
- [`v2GetBrandsBrandIdDraftsDraftId`](https://aeoapi.dev/docs/sdks/typescript/v2GetBrandsBrandIdDraftsDraftId)
- [`v2PatchBrandsBrandIdDraftsDraftId`](https://aeoapi.dev/docs/sdks/typescript/v2PatchBrandsBrandIdDraftsDraftId)
- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)

### Analytics and attribution

- [`v2GetAnalyticsDataset`](https://aeoapi.dev/docs/sdks/typescript/v2GetAnalyticsDataset)
- [`v2PostAttributionEvents`](https://aeoapi.dev/docs/sdks/typescript/v2PostAttributionEvents)

### Reports and sharing

- [`v2GetReports`](https://aeoapi.dev/docs/sdks/typescript/v2GetReports)
- [`v2PatchReports`](https://aeoapi.dev/docs/sdks/typescript/v2PatchReports)

### AI search topics

- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)

### Brand evidence

- [`v2PutBrandsBrandIdEvidenceKindKey`](https://aeoapi.dev/docs/sdks/typescript/v2PutBrandsBrandIdEvidenceKindKey)
- [`v2DeleteBrandsBrandIdEvidenceKindKey`](https://aeoapi.dev/docs/sdks/typescript/v2DeleteBrandsBrandIdEvidenceKindKey)
- [`v2GetBrandsBrandIdEvidenceKindKey`](https://aeoapi.dev/docs/sdks/typescript/v2GetBrandsBrandIdEvidenceKindKey)

### Submit to Brave

- [`v2PostRuns`](https://aeoapi.dev/docs/sdks/typescript/v2PostRuns)
- [`v2GetRunsRunId`](https://aeoapi.dev/docs/sdks/typescript/v2GetRunsRunId)
