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.

Every non-2xx response throws OnlyFansAPIError:
import { OnlyFansAPIError } from "onlyfanskit";

try {
  await of.users.retrieve("nonexistent_username");
} catch (err) {
  if (err instanceof OnlyFansAPIError) {
    console.log(err.status); // e.g. 404
    console.log(err.body);   // raw response body
    console.log(err.path);   // the request path
  }
}

What the common errors mean

StatusWhen you’ll see itWhat to do
400add a payment card (code 106)Subscribing requires a card on file, even for free creators.
400User cannot comment / can't add this post to bookmarksThe account isn’t age-verified. Many fan-side actions require it.
401Session expired or revokedReconnect the account with a fresh session.
403Not subscribed, or a creator-only endpointSubscribe first, or call from the creator’s account.
404Resource not foundCheck the id or username.
429Rate limitedBack off and retry. See Rate limiting.

Exposing errors over HTTP

When you surface SDK results through your own HTTP API, convert thrown errors into RFC 9457 problem documents so your callers — including AI agents — get a parseable, actionable contract instead of a raw stack trace:
import { errorResponse } from "onlyfanskit";

try {
  return new Response(JSON.stringify(await of.posts.create(body)));
} catch (err) {
  return errorResponse(err, { instance: request.url });
}
errorResponse classifies the failure (age verification, billing, access, rate limit, and more) and produces the right problem type automatically.