# Installation (/auth/installation)



import { Tabs, Tab } from "fumadocs-ui/components/tabs";
import { Step, Steps } from "fumadocs-ui/components/steps";
import { Card, Cards } from "fumadocs-ui/components/card";
import { TerminalIcon } from "lucide-react";

## Package Manager

Install `@onlyfansapi/auth` using your preferred package manager:

<Tabs items={['npm', 'pnpm', 'yarn', 'bun']}>
  <Tab value="npm">
    ```bash
    npm install @onlyfansapi/auth
    ```
  </Tab>

  <Tab value="pnpm">
    ```bash
    pnpm add @onlyfansapi/auth
    ```
  </Tab>

  <Tab value="yarn">
    ```bash
    yarn add @onlyfansapi/auth
    ```
  </Tab>

  <Tab value="bun">
    ```bash
    bun add @onlyfansapi/auth
    ```
  </Tab>
</Tabs>

## Prerequisites

Before you begin, make sure you have:

<Cards>
  <Card icon={<TerminalIcon className="text-fd-primary" />} href="https://app.onlyfansapi.com" title="An OnlyFans API account">
    If you don't have one yet, registering takes just a few seconds.

    <a className="flex flex-row items-center gap-1 w-fit" href="https://app.onlyfansapi.com" target="_blank">
      » Create a free account
    </a>
  </Card>
</Cards>

## Get Your API Key

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

<Steps>
  <Step>
    ### Go to the OnlyFans API console → API Keys

    Navigate to your [OnlyFans API console](https://app.onlyfansapi.com) and click on **API Keys** in the navigation menu.
  </Step>

  <Step>
    ### 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.
  </Step>
</Steps>

## 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-reference/client-sessions/create-client-session) API endpoint.

<Steps>
  <Step>
    ### Make a POST request to create a client session

    Use your API key to authenticate the request:

    ```bash
    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"`)

    <Callout type="warn">
      Other proxy countries (DE, FR, IT) have been temporarily removed due to OnlyFans restrictions. Only US and UK proxies are currently available.
    </Callout>
  </Step>

  <Step>
    ### Get the client session token from the response

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

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

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

  <Step>
    ### 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.
  </Step>
</Steps>

## Next Steps

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

* [Quick Start Guide](/auth/quickstart) - Get up and running in minutes
* [Create Client Session API Reference](/api-reference/client-sessions/create-client-session) - Full API documentation
* [NPM Package](https://www.npmjs.com/package/@onlyfansapi/auth) - Full package documentation on npm
