> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nohead.io/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript

> @nohead/sdk for Node, Bun, Deno and edge runtimes: install, configure, typed record data and raw responses.

```bash theme={null}
npm install @nohead/sdk
```

The package is ESM; Node 22+ can also `require()` it. It runs on Node 22, 24 and 26, Bun, Deno, Cloudflare Workers and other runtimes with `fetch` and Web Crypto. Use it on servers: API keys are secrets. The [overview](https://docs.nohead.io/sdks/overview.md) covers reading and writing, retries, errors, uploads and webhooks, with examples in every language.

## Configure the client

```ts theme={null}
import { Nohead } from "@nohead/sdk"

const nohead = new Nohead({
  apiKey: process.env.NOHEAD_API_KEY, // the default
  timeout: 10_000, // milliseconds per attempt
  maxRetries: 3,
})
```

| Option | Default | |
| - | - | - |
| `apiKey` | `NOHEAD_API_KEY` | A project [API key](https://docs.nohead.io/guides/api-keys.md). Required. |
| `baseUrl` | `https://api.nohead.io` | For a proxy, or a mock server in tests. |
| `projectId` | the key's project | Looked up once with `GET /v1/me` when omitted. |
| `maxRetries` | `2` | See [retries](https://docs.nohead.io/sdks/overview.md#retries-and-idempotency). |
| `timeout` | `60000` | Milliseconds per attempt. |
| `fetch` | `globalThis.fetch` | For proxies, instrumentation and tests. |
| `headers` | `{}` | Added to every request. |
| `warnings` | `true` | Logs deprecation and plan usage warnings, once each. |
| `onRetry` | | Called before each retry, with its attempt, delay, URL, status and error. |

API keys belong to a project, so methods like `collections.list()` need no project ID, and collections can be named by ID or slug.

## Typed record data

Describe a collection's fields and pass the type, and a record's `data` is typed:

```ts theme={null}
interface Post {
  title: string
  author: string
}

const post = await nohead.records.get<Post>(id) // post.data.title: string
await nohead.records.update<Post>(id, { data: { title: "Hello again" } })
```

The type is a promise you make; nothing is checked at runtime. The record type itself is `Nohead.Record<Post>`, also exported as `NoheadRecord`. Field names stay as the API sends them (`published_at`, `data`), so the [API reference](https://docs.nohead.io/api-reference/overview.md) applies as it is.

## Raw responses

`withResponse()` gives the HTTP response with the result, for its headers:

```ts theme={null}
const { data, response, requestId } = await nohead.records.get(id).withResponse()
console.log(data.id, requestId, response.headers.get("RateLimit-Remaining"))
```

## Images in frameworks

`@nohead/sdk/images` builds image URLs (`imageUrl`) and has loaders for Next.js, Astro and Nuxt Image, with no dependencies: see [Images](https://docs.nohead.io/guides/images.md#frameworks).

## Methods

Every method follows a resource of the API: `records`, `drafts`, `collections`, `fields`, `migrations`, `assets`, `webhooks`, `search`, `auditEvents` and more. Each endpoint in the [API reference](https://docs.nohead.io/api-reference/overview.md) shows its call in TypeScript, and the [README](https://github.com/nohead-io/nohead-typescript#reference) lists them by resource.

## Source

The SDK is open source, under the MIT license. Report issues and follow releases on GitHub:


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.