4BASED API · PYTHON

Use the 4Based API from Python with plain requests

4based publishes no official API. CreatorAPI gives you a hosted REST API for native 4based, 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, Fansly and 4based

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 4based creator id you get when you connect an account

Read subscribers by shorthand

Subscribers come back as structured JSON from one GET request. 4based buries the creator's own id in almost every path, so CreatorAPI gives you a shorthand instead: subscribers resolves to the real path and fills in the id for you.

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

Read earnings and everything else

Earnings, tiers, chats, feed and vault are all reads on the same route pattern, so one helper covers the whole 4based surface. The exact shorthands and raw paths are listed in the 4Based API reference.

def native_get(path, **params):
    # works for any read shorthand: me, subscribers, tiers, chats, feed, vault, earnings
    r = session.get(f"{BASE}/v1/{account}/native/{path}", params=params)
    r.raise_for_status()
    return r.json()

# earnings for a date range
earnings = native_get("earnings", init_from="2026-01-01", init_to="2026-07-01")

Start a data export

A single POST starts a bulk export of subscribers or chats 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 working calls.

One file, full reference

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

Describe, then run

Ask for a script that pulls 4based 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 the 4Based CRM API for what to build on top.

Python questions

Does 4based have an official Python SDK?

No. 4based publishes no official public API or SDK. CreatorAPI is a hosted REST API that calls the same authenticated endpoints the 4based app uses, 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?

Profile, subscribers, subscription tiers, conversations, messages, feed, vault and earnings, all through shorthand aliases under /v1/{account}/native/.

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.

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 OnlyFans and Fansly?

Yes. One key covers OnlyFans, Fansly and 4based, and the route pattern is identical, so the same Python client works across all three.

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