> ## 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.

# C# SDK

> Official OFAuth C# SDK — DI support, CancellationToken, 473 model classes

```bash theme={null}
dotnet add package OnlyFans.SDK
```

## Quick Example

```csharp theme={null}
using OFAuth;

var client = new OFAuthClient("your-api-key");

var account = await client.GetAsync<WhoamiResponse>("/v2/account/whoami");
Console.WriteLine($"{account.Id} {string.Join(", ", account.Permissions)}");
```

## Details

|                  | C#                                                                       |
| ---------------- | ------------------------------------------------------------------------ |
| **Package**      | `OnlyFans.SDK`                                                           |
| **Repository**   | [onlyfans-sdk-csharp](https://github.com/OFAuth-org/onlyfans-sdk-csharp) |
| **Init**         | `new OFAuthClient()`                                                     |
| **Architecture** | `GetAsync<T>(path)` with 473 model classes                               |
| **Types**        | Generated classes with `JsonPropertyName`                                |
| **Pagination**   | Manual (query params)                                                    |
| **Dependencies** | `System.Net.Http`, `System.Text.Json`                                    |

## Features

<CardGroup cols={2}>
  <Card title="DI Support" icon="code">
    Register `OFAuthClient` in your DI container with `IHttpClientFactory`.
  </Card>

  <Card title="CancellationToken" icon="circle-stop">
    Every async method accepts `CancellationToken` for cooperative cancellation.
  </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

```csharp theme={null}
var subs = await client.GetAsync<ListSubscribersResponse>(
    "/v2/access/subscribers?limit=20",
    connectionId: "conn_xxx"
);

foreach (var sub in subs.Data)
{
    Console.WriteLine($"{sub.Username} {sub.SubscribedAt}");
}
```

### Send a message

```csharp theme={null}
await client.PostAsync("/v2/access/chats/12345/messages",
    new { text = "Hello from OFAuth!" },
    connectionId: "conn_xxx"
);
```

### Error handling

```csharp theme={null}
try
{
    await client.GetAsync<UserResponse>(
        "/v2/access/users/999",
        connectionId: "conn_xxx"
    );
}
catch (OFAuthException ex)
{
    Console.WriteLine($"{ex.Status} {ex.Code} {ex.Message}");
}
```
