ofapisv1
quickstart

OnlyFans API — Node.js Quickstart

Talk to the OnlyFans API from Node.js using native fetch (Node 18+). Grab a token from the dashboard and you're a few lines from your first call. Every request targets https://api.ofapis.com/api/public/v1.

1. Setup

Native fetch is built into Node 18+, so no dependency is needed. Create a project and load your token from the environment — never commit it:

npm init -y
export OFAPIS_KEY="ofapis_sk_..."

On Node 16 or older, npm install node-fetch and import it instead. Grab a token from the dashboard (start free); details in the authentication guide.

2. Authenticate — GET /me

Send the Bearer token on every request. GET /me returns the connected creator profile and confirms the key works:

const BASE = "https://api.ofapis.com/api/public/v1";
const headers = { Authorization: `Bearer ${process.env.OFAPIS_KEY}` };

const res = await fetch(`${BASE}/me`, { headers });
if (!res.ok) throw new Error(`/me failed: ${res.status}`);
console.log(await res.json());

A 200 returns the profile and meters one credit; failures are free.

3. List chats

const res = await fetch(`${BASE}/chats?limit=50`, { headers });
const { data = [] } = await res.json();
for (const chat of data) console.log(chat.id);

4. Send a message

Wrap writes in error handling — fetch only rejects on network errors, so you must check res.ok yourself for 4xx/5xx:

async function sendMessage(chatId, text) {
  const res = await fetch(`${BASE}/chats/${chatId}/messages`, {
    method: "POST",
    headers: { ...headers, "Content-Type": "application/json" },
    body: JSON.stringify({ text }),
  });
  if (res.status === 429) throw new Error("rate limited — back off");
  if (!res.ok) throw new Error(`send failed: ${res.status}`);
  return res.json(); // 200 — delivered, 1 credit spent
}

await sendMessage("123", "Thanks for subscribing!");

Failed calls — expired session, 429, upstream 5xx — are never charged, so retrying a failure costs nothing.

5. Agencies: scope by account

Managing several creators? Address each by id under scoped routes:

await fetch(`${BASE}/accounts/42/chats`, { headers });

FAQ

Which Node.js version do I need for the OnlyFans API?

Node 18+ ships native fetch, so no HTTP dependency is required. On Node 16 or older, install node-fetch or use axios and keep the same header and body shapes.

How do I handle rate limits in Node?

fetch does not throw on 429, so check res.status and back off before retrying. Plan ceilings run from 60 rpm on Free to 500 rpm on Pro — see pricing.

Does a failed fetch cost a credit?

No. Only successful calls are metered: one 2xx response equals one credit. Network errors, 429s, and upstream 5xx responses are not charged.

Can I generate a TypeScript client?

Yes. Point openapi-typescript or a similar generator at the OpenAPI spec in the docs and playground for fully typed request and response models.

Next steps

Related: Rust · Java

Related guides

All guides
Start free — 250 credits, no card
Generate a token and make your first call in minutes.
Get started