Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.onlyfanskit.dev/llms.txt

Use this file to discover all available pages before exploring further.

The client takes a connected account’s session. Authentication is handled for you — you supply the session, the SDK does the rest.
import { OnlyFans } from "onlyfanskit";

const of = new OnlyFans({
  cookie: "<your-cookie>",
  xBc: "<your-x-bc>",
  userId: "123456789",
  userAgent: "<your-user-agent>",
  // fetch: myFetch,   // optional — bring your own transport
});

Required options

OptionDescription
cookieThe account’s session cookie.
xBcThe account’s x-bc value.
userIdNumeric OnlyFans user id for the account.
userAgentThe user agent to send. Keep it stable per account.

Optional options

OptionDescription
fetchA fetch-compatible function. Use it to route requests through your own transport or network egress.

Where the session comes from

The SDK acts as a connected account, so it needs that account’s cookie, xBc, and userId. You can:
  • Use the CLI connect flow to capture them interactively.
  • Extract them from a logged-in browser session.
  • Let the REST API handle connecting and storage for you, if you’d rather not manage sessions in your own code.
userIdFromCookie(cookie) (from onlyfanskit/connect) reads the numeric id out of a session cookie, so you don’t have to pass userId separately.

Helpers

import { parseCurlConnect, userIdFromCookie } from "onlyfanskit/connect";

const { cookie, xBc, userAgent } = parseCurlConnect(curlExport);
const userId = userIdFromCookie(cookie ?? "");

Keeping a session healthy

Sessions can expire. When a call fails because the session is no longer valid, reconnect the account (a fresh cookie, or a new login) and construct a new client. The REST API automates this with stored credentials and reauthentication.