Getting Started
Quickstart
Make your first OnlyFans API call in under 2 minutes with the OFManager API. 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 an API key and the SDK installed
- Your
OFM_API_KEYis in your environment - You know the OnlyFans user ID of the account you're operating on (listed under Linked OnlyFans accounts on the API Keys page)
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.OFM_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", skip_users: "all" },
})
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 live events
Open a live connection for the same creator to get new messages and new subscribers the moment they happen:
import { OfWsClient } from "@betterfans/link-sdk"
const ws = new OfWsClient({
apiKey: process.env.OFM_API_KEY,
auth: { onlyfansUserId: "123456789" },
})
ws.on("api2_chat_message", (msg) => {
console.log(`New message from ${msg.fromUser?.name ?? "someone"}: ${msg.text}`)
})
ws.on("subscribed", (event) => {
console.log(`New subscriber: ${event.user.name}`)
})
ws.connect()Next steps
- HTTP Client: Learn about request patterns, error handling, and retries.
- Batch requests: Send multiple requests in a single call.
- Live events: Get every creator's messages, subscribers and more as they happen.