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

# TypeScript SDK

> Official OFAuth TypeScript SDK — full type safety, async iterators, zero dependencies

```bash theme={null}
npm install @ofauth/onlyfans-sdk
```

## Quick Example

```typescript theme={null}
import { createOFAuthClient } from '@ofauth/onlyfans-sdk';

const client = createOFAuthClient({ apiKey: 'your-api-key' });

const account = await client.account.whoami();
console.log(account.id, account.permissions);
```

## Details

|                  | TypeScript                                                                       |
| ---------------- | -------------------------------------------------------------------------------- |
| **Package**      | `@ofauth/onlyfans-sdk`                                                           |
| **Repository**   | [onlyfans-sdk-typescript](https://github.com/OFAuth-org/onlyfans-sdk-typescript) |
| **Init**         | `createOFAuthClient()`                                                           |
| **Architecture** | Nested client with namespaces                                                    |
| **Types**        | Inline types, full IntelliSense                                                  |
| **Pagination**   | Async iterators (`for await`)                                                    |
| **Dependencies** | None (uses `fetch`)                                                              |

## Features

<CardGroup cols={2}>
  <Card title="Full Type Safety" icon="code">
    Generated from the OpenAPI spec — response types, request params, and error codes are all typed.
  </Card>

  <Card title="Async Iterators" icon="arrows-rotate">
    `for await` over any paginated list automatically.
  </Card>

  <Card title="Proxy Support" icon="globe">
    Call any OnlyFans endpoint directly through the OFAuth proxy.
  </Card>

  <Card title="Media Upload" icon="cloud-arrow-up">
    Automatic chunking and progress callbacks.
  </Card>
</CardGroup>

## Usage Examples

### List subscribers

```typescript theme={null}
const subscribers = await client.access.listSubscribers({
  connectionId: 'conn_xxx',
  limit: 20
});

for (const sub of subscribers.data) {
  console.log(sub.username, sub.subscribedAt);
}
```

### Send a message

```typescript theme={null}
await client.access.sendMessage({
  connectionId: 'conn_xxx',
  userId: '12345',
  text: 'Hello from OFAuth!'
});
```

### Error handling

```typescript theme={null}
import { OFAuthAPIError } from '@ofauth/onlyfans-sdk';

try {
  await client.access.getUser({ connectionId: 'conn_xxx', userId: '999' });
} catch (err) {
  if (err instanceof OFAuthAPIError) {
    console.error(err.status, err.code, err.message);
  }
}
```
