BetterFans Link SDK — OnlyFans APIBetterFans Link SDK
Core Capabilities

Realtime

Aggregate chat counts and notification events from the WebSocket EventBus.

The realtime plugins give you computed state from the EventBus — per-account chat counts and deduplicated notification events — without manually parsing raw WebSocket frames.

Realtime counts

Maintains an in-memory snapshot of chat and notification counts per account, updated live from WebSocket events.

import { realtimeCounts } from "@betterfans/link-sdk/plugins/realtime-counts"

const counts = realtimeCounts()

Reading counts

// Get counts for a specific account
const accountCounts = counts.api.getAccountCounts("123456789")

if (accountCounts) {
  console.log("Unread chats:", accountCounts.chats.unread)
  console.log("Priority chats:", accountCounts.chats.priority)
  console.log("Notifications:", accountCounts.notifications.new)
}

// Get the full snapshot across all accounts
const snapshot = counts.api.getSnapshot()
console.log("Initialized:", snapshot.initialized)

for (const [accountId, state] of snapshot.accounts) {
  console.log(accountId, state.chats.unread)
}

Subscribing to changes

React to count updates as they arrive:

const unsubscribe = counts.api.subscribe(() => {
  const snapshot = counts.api.getSnapshot()
  // re-render your UI, update a badge, etc.
})

// later
unsubscribe()

API

Prop

Type

Notification events

Surfaces engagement-critical events — tips, PPV purchases, new and returning subscribers — as a deduplicated stream with a 5-second dedup window.

import { notificationEvents } from "@betterfans/link-sdk/plugins/notification-events"

const notifications = notificationEvents()

Event types

EventTriggered when
tipA tip is received
ppv_purchaseA pay-per-view message is purchased
new_subscriberA new user subscribes
returning_subscriberA previously expired subscriber resubscribes
fan_messageA fan sends a message

Subscribing to events

const unsubscribe = notifications.api.subscribe(() => {
  const { latestEvent, eventCount } = notifications.api.getSnapshot()

  if (latestEvent) {
    console.log(
      `[${latestEvent.type}]`,
      `Account: ${latestEvent.accountId}`,
      `Amount: ${latestEvent.amount}`,
    )
  }
})

Clearing

// Clear the latest event (e.g. after displaying a toast)
notifications.api.clearEvent()

API

Prop

Type

On this page