Quickstart
Make your first OnlyFans API call in under 2 minutes with the BetterFans Link SDK — the infrastructure behind OFManager. Fetch profiles, list chats, send messages, and listen to real-time events.
This guide walks you through creating a client, fetching your profile, listing recent chats, and sending a message — all with full type safety.
Prerequisites
- You have API access and the SDK installed
- Your
BFL_API_KEYis in your environment - You know the OnlyFans user ID of the account you're operating on
Fetch your profile
Every request targets a specific OnlyFans account. Use .for() to
scope the client to an account ID, then call any route:
import { OfApiClient } from "@betterfans/link-sdk"
const client = new OfApiClient({
apiKey: process.env.BFL_API_KEY,
})
const account = client.for("123456789")
const [error, me] = await account.request("GET /users/me", {})
if (error) {
console.error(error.code, error.message)
process.exit(1)
}
console.log(me.name, me.username)
// → "Jane Doe" "janedoe"The me object is fully typed as UserFull — your editor
autocompletes every field.
List recent chats
Pass query parameters to control the results:
const [error, chats] = await account.request("GET /chats", {
query: { limit: 10, offset: 0, order: "recent" },
})
if (!error) {
for (const chat of chats.list) {
const user = chat.withUser
console.log(`${user.name}: ${chat.lastMessage?.text ?? "(media)"}`)
}
}Send a message
Write operations use POST, PUT, or DELETE routes. The SDK
enforces the correct body shape at compile time:
import { markdownToHtml } from "@betterfans/link-sdk/utils"
const [error, message] = await account.request(
"POST /chats/:id/messages",
{
pathParams: { id: "98765" },
body: {
text: markdownToHtml("Hey! Thanks for subscribing"),
},
},
)
if (!error) {
console.log("Sent:", message.id)
}Listen for real-time events
Connect to the EventBus to receive events like new messages, tips, and subscriber activity:
import { OfWsClient } from "@betterfans/link-sdk"
const ws = new OfWsClient({
apiKey: process.env.BFL_API_KEY,
wsToken: process.env.BFL_WS_TOKEN,
subscribe: ["chat_message", "new_subscriber", "tip"],
})
ws.on("chat_message", (event) => {
console.log(`New message from account ${event.accountId}`)
})
ws.on("new_subscriber", (event) => {
console.log(`New subscriber: ${event.userId}`)
})
ws.connect()Next steps
Getting OnlyFans API Access
How to get OnlyFans API access. Create an account on OFManager (the leading OnlyFans agency management platform), link your creators, and get your BetterFans Link SDK API key instantly.
OnlyFans Chat Bot in 50 Lines
Build an OnlyFans chatbot that auto-replies across multiple creator accounts using the BetterFans Link SDK — the OnlyFans API, the infrastructure behind OFManager.