ONLYFANS API · PYTHON

Use the OnlyFans API from Python with plain requests

OnlyFans publishes no official API. CreatorAPI gives you a hosted REST API for native OnlyFans and Fansly access, and any Python HTTP client can call it: one key, one header, stable JSON back.

Start free with 1,000 credits · no card · one key for OnlyFans and Fansly

Set up the client

All you need is the requests library and your API key in the X-API-Key header. Keep the key in an environment variable, never in code, and reuse one session so the header rides along on every call.

# pip install requests
import os, requests

BASE = "https://api.creator-api.com"
session = requests.Session()
session.headers["X-API-Key"] = os.environ["CREATOR_API_KEY"]

account = os.environ["CREATOR_ACCOUNT_ID"]  # the creator id you get when you connect an account

Read subscribers

Subscribers come back as structured JSON from one GET request. Every native route follows the same pattern: /v1/{account}/native/{path}, and each read costs 1 credit.

# list the newest 50 subscribers
r = session.get(
    f"{BASE}/v1/{account}/native/subscriptions/subscribers",
    params={"limit": 50},
)
r.raise_for_status()
print(r.json())

Read earnings and everything else

Earnings, transactions, messages, fans, media and posts are all reads on the same route pattern, so one helper covers the whole surface. The exact paths for all 89 verified GET routes are listed in the OnlyFans API reference.

def native_get(path, **params):
    # works for any read path from the reference: earnings, transactions, posts, fans
    r = session.get(f"{BASE}/v1/{account}/native/{path}", params=params)
    r.raise_for_status()
    return r.json()

Start a data export

A single POST starts a bulk export of subscribers, transactions, chats or posts to CSV or JSONL. One export job costs 10 credits, and you download the file when the job is done.

# export all subscribers to CSV, 10 credits per job
job = session.post(
    f"{BASE}/v1/{account}/exports",
    json={"dataset": "subscribers", "format": "csv"},
)
job.raise_for_status()
print(job.json())

Webhooks and errors

Webhook deliveries are signed with HMAC SHA256 and retried with backoff, so your Python service can trust what arrives and verify it in a few lines. The quickstart walks through signature verification. Errors are plain HTTP: 401 for a bad key, 402 when credits run out, 429 on rate limits, always with a JSON body of {"error": "..."}, so raise_for_status() plus one except block covers you.

Or let an AI write the Python for you

The whole API fits in one file made for language models. Paste it into Claude or Codex and describe what you want; the model writes the calls.

One file, full reference

Grab https://api.creator-api.com/llms-full.txt and paste it into your AI chat. Every route, parameter and error is in there.

Describe, then run

Ask for a script that pulls subscribers into a spreadsheet or flags churn risks. The model writes working requests code against real routes.

Grow it into a product

Once the reads work, the same key powers webhooks, tags and exports. See how to build an OnlyFans CRM on top.

Python questions

Does OnlyFans have an official Python SDK?

No. OnlyFans publishes no official public API or SDK. CreatorAPI is a hosted REST API that calls the same authenticated endpoints the platform apps use, and you reach it from Python with any HTTP client such as requests.

How do I authenticate from Python?

Send your key in the X-API-Key header on every request. Store it in an environment variable and load it with os.environ, never hardcode it.

What data can I read from Python?

Fans, messages, media, earnings, posts, transactions and subscribers, all through one route pattern under /v1/{account}/native/. There are 194 OnlyFans capabilities, with 89 GET routes live verified.

How much does each call cost?

A native read costs 1 credit, a write 2 credits, and an export job 10 credits. The free trial includes 1,000 credits with no card required.

How do I verify webhooks in Python?

Every webhook delivery is signed with HMAC SHA256, and deliveries retry with backoff. The quickstart shows how to verify the signature before you trust the payload.

Can an AI write the Python code for me?

Yes. CreatorAPI publishes its whole API reference in one text file made for language models. Paste it into Claude or Codex, describe what you want, and the model writes working calls.

Does the same code work for Fansly?

Yes. One key covers both OnlyFans and Fansly, and the route pattern is identical, so the same Python client works across platforms.

Ship your first Python integration today

Start free with 1,000 credits, no card required, and make your first call in minutes.

Start free with 1,000 credits · no card