NewFans API, previously OnlyFans API · A new name. A broader platform.
Fans API

Installation

Install and set up @onlyfansapi/auth in your project

Package Manager

Install @onlyfansapi/auth using your preferred package manager:

npm install @onlyfansapi/auth
pnpm add @onlyfansapi/auth
yarn add @onlyfansapi/auth
bun add @onlyfansapi/auth

Prerequisites

Before you begin, make sure you have:

Get Your API Key

Before creating a client session token, you'll need an API key to authenticate your requests to Fans API.

Go to the Fans API console → API Keys

Navigate to your Fans API console and click on API Keys in the navigation menu.

Create a new API key

Click the "Create API Key" button to generate a new API key.

Copy and save your API key securely - you'll need it to create client session tokens.

Create Your Client Session Token

To use @onlyfansapi/auth, you'll need to create a client session token (starts with ofapi_cs_) through the Create Client Session API endpoint.

Make a POST request to create a client session

Use your API key to authenticate the request:

curl -X POST "https://app.onlyfansapi.com/api/client-sessions" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "display_name": "My Application / Model: John Doe"
  }'

Optional fields:

  • client_reference_id - Your internal reference ID for the connected account
  • proxy_country - Proxy country value ("us" | "uk")

Other proxy countries (DE, FR, IT) have been temporarily removed due to OnlyFans restrictions. Only US and UK proxies are currently available.

Get the client session token from the response

The response will include a token field that starts with ofapi_cs_:

{
  "data": {
    "token": "ofapi_cs_OriR8Sdocp0f97eFOdbMMZtiz4Aw5FLX",
    "display_name": "My Application / Model: John Doe"
  }
}

This token is what you'll use with the @onlyfansapi/auth package.

Use the client session token

Copy the client session token and use it in your application with @onlyfansapi/auth.

Important: Keep your client session token secure. While it's designed for client-side use, treat it with appropriate security measures.

Create a token for an existing account

For reconnection, make the same backend request with { "account_id": "acct_XXXXXXXXXX" } instead of the new-connection fields. Do not send display_name, client_reference_id, proxy_country, scopes, or app_name; the account's settings and permissions are preserved.

Authorize the current user's access to the selected account in your application before requesting a token. Team ownership and API-key account restrictions are also checked by Fans API. Return data.token only to that user's frontend, then call updateOnlyFansCredentials(token, options).

Update tokens accept submissions and retries for 30 minutes and cannot start another update after success. Fetch tokens from your backend when needed; do not use a static public environment variable.

Next Steps

Once you've installed the package and created your client session token, you're ready to start implementing authentication in your application.

On this page