npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ofauth/onlyfans-sdk

v3.0.0

Published

OFAuth API TypeScript SDK v2 - Nested client structure

Readme

OnlyFans API - TypeScript SDK

npm JSR License

The official OnlyFans API TypeScript SDK by OFAuth. A type-safe, fully-typed client for integrating with the OnlyFans API. Build OnlyFans tools, dashboards, analytics, and automations with full IntelliSense support.

What is this? This is an SDK for the OnlyFans API via OFAuth — the only authorized way to programmatically access OnlyFans data. Use it to build OnlyFans integrations, manage creator accounts, access earnings data, automate messaging, and more.

Installation

# npm
npm install @ofauth/onlyfans-sdk

# yarn
yarn add @ofauth/onlyfans-sdk

# pnpm
pnpm add @ofauth/onlyfans-sdk

# JSR (Deno / JSR registry)
npx jsr add @ofauth-org/onlyfans-sdk

Quick Start

import { createOFAuthClient } from '@ofauth/onlyfans-sdk';

const client = createOFAuthClient({ apiKey: 'your-api-key' });

// Get account info
const account = await client.whoami();
console.log(account.id, account.permissions);

Features

  • Full TypeScript support with inline types
  • Nested client structure for intuitive API navigation
  • Async iterators for paginated endpoints
  • Proxy support for direct OnlyFans API access
  • Media upload with automatic chunking
  • Webhook verification and routing (Svix-compatible)

Configuration

import { createOFAuthClient } from '@ofauth/onlyfans-sdk';

const client = createOFAuthClient({
  apiKey: 'your-api-key',
  // Optional: Set a default connection ID for all requests
  connectionId: 'conn_xxx',
  // Optional: Custom base URL
  basePath: 'https://api-next.ofauth.com',
  // Optional: Custom fetch implementation
  fetchApi: customFetch,
});

Usage Examples

Account Operations

// Get account info
const account = await client.whoami();

// List all connections
const connections = await client.account.connections.list();
for (const conn of connections.list) {
  console.log(conn.id, conn.status, conn.userData.username);
}

// Get connection settings
const settings = await client.account.connections.getSettings('conn_xxx');

Pagination with Iterators

For endpoints that return paginated data, use the iterate() method:

// Iterate over all connections (handles pagination automatically)
for await (const connection of client.account.connections.iterate()) {
  console.log(connection.id);
}

// With options
for await (const connection of client.account.connections.iterate({
  maxItems: 100,  // Stop after 100 items
  pageSize: 20,   // Items per page
})) {
  console.log(connection.id);
}

Access API (OnlyFans Data)

Access endpoints require a connection ID:

// Set connection ID for all requests
const client = createOFAuthClient({
  apiKey: 'your-api-key',
  connectionId: 'conn_xxx',
});

// Or pass it per-request
const profile = await client.access.self.get({ connectionId: 'conn_xxx' });

// Get earnings data
const earnings = await client.access.earnings.chart.get({
  startDate: '2024-01-01',
  endDate: '2024-01-31',
});

// List posts
const posts = await client.access.posts.list({ limit: 20 });

// Iterate over all posts
for await (const post of client.access.posts.iterate()) {
  console.log(post.id, post.text);
}

Proxy Requests

Call any OnlyFans API endpoint directly:

// GET request
const user = await client.proxy({
  path: '/users/me',
  method: 'GET',
  connectionId: 'conn_xxx',
});

// POST request with body
const response = await client.proxy({
  path: '/messages/queue',
  method: 'POST',
  connectionId: 'conn_xxx',
  body: {
    text: 'Hello!',
    lockedText: false,
  },
});

// With query parameters
const subscribers = await client.proxy({
  path: '/subscriptions/subscribers',
  method: 'GET',
  connectionId: 'conn_xxx',
  query: { limit: 10 },
});

Media Upload

// Upload from File object (browser)
const result = await client.access.uploads.upload(
  'conn_xxx',
  file,  // File object
  { onProgress: (uploaded, total) => console.log(`${uploaded}/${total}`) }
);

// Upload from Buffer (Node.js)
import fs from 'fs';

const buffer = fs.readFileSync('video.mp4');
const result = await client.access.uploads.upload(
  'conn_xxx',
  new Blob([buffer], { type: 'video/mp4' }),
  { filename: 'video.mp4' }
);

Error Handling

import { OFAuthAPIError } from '@ofauth/onlyfans-sdk';

try {
  const account = await client.whoami();
} catch (error) {
  if (error instanceof OFAuthAPIError) {
    console.error('API Error:', error.status, error.message);
    console.error('Error code:', error.code);
    console.error('Details:', error.details);
  } else {
    throw error;
  }
}

Type Safety

All request and response types are generated from the OpenAPI spec:

import type {
  AccountWhoamiResponse,
  AccountConnectionsListResponse,
  AccountConnectionsListItem,
  AccessSelfGetResponse,
} from '@ofauth/onlyfans-sdk';

// Response types are automatically inferred
const account = await client.whoami();
// account: AccountWhoamiResponse

// Full IntelliSense support
account.id;          // string
account.name;        // string | null
account.permissions; // string[]

API Reference

The client provides access to these API namespaces:

  • client.whoami() - Account info
  • client.account.connections - Connection management
  • client.account.settings - Account settings
  • client.access.self - Creator profile
  • client.access.posts - Posts management
  • client.access.chats - Chat/messages
  • client.access.subscribers - Subscriber data
  • client.access.earnings - Earnings & analytics
  • client.access.vault - Vault media
  • client.access.promotions - Promotions & links
  • client.access.uploads - Media uploads
  • client.proxy() - Direct OnlyFans API access

License

MIT