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
| Event | Triggered when |
|---|---|
tip | A tip is received |
ppv_purchase | A pay-per-view message is purchased |
new_subscriber | A new user subscribes |
returning_subscriber | A previously expired subscriber resubscribes |
fan_message | A 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
Media
Upload photos and videos to OnlyFans programmatically via the BetterFans Link SDK — the infrastructure behind OFManager. One call per upload, deduplication built in, ready to attach to messages and posts.
HTTP Client
Create and configure the OfApiClient for making typed OnlyFans API requests via the BetterFans Link SDK — the infrastructure behind OFManager. Every route, parameter, and response is fully typed at compile time.