We just released our native n8n integration!» Try now
OnlyFans 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 the OnlyFans API.

Go to the OnlyFans API console → API Keys

Navigate to your OnlyFans 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" | "de" | "fr" | "it")

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.

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