HTTP Client
HTTP Client
Create and configure the OfApiClient for making typed OnlyFans API requests with the OFManager API. Every route, parameter, and response is fully typed at compile time.
The OfApiClient is the primary interface for making typed HTTP
requests to the OnlyFans API. Every request is fully typed: routes,
parameters, bodies, and responses all have compile-time guarantees.
import { OfApiClient } from "@betterfans/link-sdk"
const client = new OfApiClient({
apiKey: process.env.OFM_API_KEY,
})Configuration
The client accepts the following options:
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | Your API key. | |
fetch | (input: RequestInfo, init?: RequestInit) => Promise<Response> | globalThis.fetch | Custom fetch implementation. Useful for testing or environments without global fetch. |
retry | RetryConfig | { maxAttempts: 3, backoffMs: 1000 } | Default retry configuration for GET requests. See Error Handling for details. |
debug | boolean | false | When true, logs request/response details to the console. |
How requests work
You write a route string like "GET /chats" and the SDK handles
everything else: constructing the request, authenticating, and
returning a typed response. No manual URL building, header management,
or response parsing.
const [error, chats] = await account.request("GET /chats", {
query: { limit: 20 },
})
// chats is fully typed — autocomplete works on every fieldNext steps
- Making requests: Learn the request/fetch pattern and verb shortcuts.
- Scoped clients: Bind a client to a specific OnlyFans account.
- Error handling: Handle errors, configure retries, and understand error codes.