API docs / HTTP Client

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:

OptionTypeDefaultDescription
apiKeystringYour API key.
fetch(input: RequestInfo, init?: RequestInit) => Promise<Response>globalThis.fetchCustom fetch implementation. Useful for testing or environments without global fetch.
retryRetryConfig{ maxAttempts: 3, backoffMs: 1000 }Default retry configuration for GET requests. See Error Handling for details.
debugbooleanfalseWhen 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 field

Next steps