RAG & Search

Two complementary query APIs for your synced data. Use Semantic Search to find messages by meaning, or the Query DSL for precise structured queries across messages, chats, fans, and chunks.

Authentication

Both endpoints require an X-API-Key header. The key determines the organization scope — all results are automatically restricted to models belonging to your organization. You cannot query data outside your org regardless of filter values.

Query DSL

Structured queries across six whitelisted tables. All results are scoped to your organization — model_id values are validated against your org's connected models.

curl -X POST "https://api.onlyfans-api.ai/api/query" \
  -H "X-API-Key: sk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"table": "messages", "filters": {"fan_platform_id": {"eq": "553393565"}, "is_from_model": false}, "sort": {"field": "created_at", "direction": "desc"}, "limit": 5}'
ParameterTypeDescription
tablerequired
stringTable to query. One of: messages, chats, fans, message_chunks, message_tags, of_daily_stats.
filters
objectFilter conditions keyed by field name. Each value is an operator object e.g. {"gte": "2026-01-01"}. See filter operators below.
fields
arrayList of field aliases to return. Omit to return all default fields for the table. Opt-in fields (listed per table under Available Tables) are returned only when you name them here.
sort.field
stringField to sort by. Must be one of the table's sortable fields. of_daily_stats defaults to stat_date.Default: created_at
sort.direction
stringSort direction: asc or desc.Default: asc
limit
integerNumber of rows to return. Maximum 1000.Default: 20
offset
integerPagination offset.Default: 0
include_raw_payload
booleanmessages table only. When true, each row includes the full raw OnlyFans payload.Default: false
include_deleted
booleanmessages table only. Messages unsent on OnlyFans are hidden by default. When true, they are returned too, and each row includes its deleted_at (null for a message that was not unsent).Default: false
Response — messages
{
  "table": "messages",
  "total": 1482,
  "limit": 5,
  "offset": 0,
  "data": [
    {
      "message_id": "9d5b817a-eced-46b6-831c-f68fbbaed798",
      "platform_message_id": "9130375619415",
      "fan_platform_id": "553393565",
      "model_id": "16f3d13b-9415-4e6b-babe-e8db6b31bd97",
      "created_at": "2026-05-10T14:32:00+00:00",
      "message_text": "I love outdoor hiking and photography",
      "price": 0,
      "is_tip": false,
      "media_count": 0,
      "is_from_model": false
    }
  ]
}
curl -X POST "https://api.onlyfans-api.ai/api/query" \
  -H "X-API-Key: sk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"table": "fans", "filters": {"total_spent": {"gte": 100}}, "sort": {"field": "total_spent", "direction": "desc"}, "limit": 3}'
Response — fans
{
  "table": "fans",
  "total": 358,
  "limit": 3,
  "offset": 0,
  "data": [
    {
      "fan_id": "c1d2e3f4-a5b6-7890-cdef-012345678901",
      "fan_platform_id": "553393565",
      "model_id": "16f3d13b-9415-4e6b-babe-e8db6b31bd97",
      "display_name": "Harry",
      "username": "sirharoldprince",
      "total_spent": 2171.50,
      "tips_spent": 1460.00,
      "messages_spent": 597.50,
      "subscribed_on": true,
      "last_seen": "2026-06-18T09:14:00+00:00",
      "can_receive_message": true,
      "is_blocked": false,
      "created_at": "2025-10-02T11:00:00+00:00",
      "updated_at": "2026-06-18T09:14:00+00:00"
    }
  ]
}
curl -X POST "https://api.onlyfans-api.ai/api/query" \
  -H "X-API-Key: sk_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"table": "of_daily_stats", "filters": {"model_id": "16f3d13b-9415-4e6b-babe-e8db6b31bd97", "stat_date": {"gte": "2026-10-01", "lte": "2026-10-03"}}}'
Response — of_daily_stats
{
  "table": "of_daily_stats",
  "total": 3,
  "limit": 20,
  "offset": 0,
  "data": [
    {
      "model_id": "16f3d13b-9415-4e6b-babe-e8db6b31bd97",
      "platform": "onlyfans",
      "stat_date": "2026-10-01",
      "gross_amount": "125.50",
      "net_amount": "100.40",
      "synced_at": "2026-10-01T05:00:11+00:00"
    },
    {
      "model_id": "16f3d13b-9415-4e6b-babe-e8db6b31bd97",
      "platform": "onlyfans",
      "stat_date": "2026-10-02",
      "gross_amount": "0.00",
      "net_amount": "0.00",
      "synced_at": "2026-10-02T05:00:09+00:00"
    },
    {
      "model_id": "16f3d13b-9415-4e6b-babe-e8db6b31bd97",
      "platform": "onlyfans",
      "stat_date": "2026-10-03",
      "gross_amount": "210.25",
      "net_amount": "168.20",
      "synced_at": "2026-10-03T05:00:12+00:00"
    }
  ]
}

Available Tables

Each table exposes a fixed set of filterable and returnable fields. You cannot query tables or fields not listed here.

Opt-in fields

Opt-in fields are not part of the default response. Name them in fields to read them, e.g. "fields": ["platform_message_id", "reply_to_message"]. reply_to_message is the quoted message of a reply: an object with id, text, createdAt and fromUser, or null when the message is not a reply. The snapshot fields (is_pinned, is_liked, is_added_to_bookmarks, is_new, is_reported_by_me, is_canceled, is_media_ready) hold the value from when the message was first synced and are not updated afterwards: a pin, like or bookmark made later does not show up in them.

of_daily_stats

One row per model per day, with gross_amount and net_amount summed across every earning category OnlyFans reports for that day. Only the daily total is stored, not the individual earnings. Amounts are decimal strings with two decimals ("432.14"), not numbers. stat_date is a UTC calendar day (YYYY-MM-DD), so a day can differ from the OnlyFans dashboard, which shows your local time. Filter it with gte, lte or eq. A day with no earnings is stored as 0.00; days before a model's first sync have no row. The daily sync runs at 05:00 UTC and rewrites the rows of today and of the two days before it, so today's row is a snapshot of the latest run (at most the first hours of the day), a day is complete once the 05:00 UTC run of the next day has written it, and it can still change slightly until the run after that. Older days are not rewritten. synced_at is when the row was last written.
messagesSynced message records from fan conversations.
Filter fieldscreated_at, is_from_model, price, is_tip, media_count, message_text, fan_platform_id, model_id, is_from_queue, can_purchase_reason, changed_at, platform_message_id, queue_id (these two take eq and in, up to 500 values: look messages up by id, or find every message of one mass or welcome send by its queue id; queue_id is returned when named in fields)
Sort fieldscreated_at, price, media_count
Return fieldsmessage_id, platform_message_id, fan_platform_id, model_id, created_at, message_text, price, is_tip, media_count, is_from_model, giphy_id, is_from_queue, can_purchase_reason, changed_at
Opt-in fieldsraw_payload (via include_raw_payload: true), deleted_at (via include_deleted: true). Named in fields: chat_id, sender_platform_id, synced_at, locked_text, is_free, from_user, to_user, previews, release_forms, reply_to_message, queue_id, response_type, chat_user_id, cancel_seconds, can_unsend_queue, unsend_seconds_queue, tip_text, tip_amount, is_fund_raising_tip, is_couple_people_media, is_markdown_disabled, can_report, can_be_pinned, is_opened, can_purchase. Snapshot, not live (see the note above): is_pinned, is_liked, is_added_to_bookmarks, is_new, is_reported_by_me, is_canceled, is_media_ready
chatsChat thread records — one per fan–model pair.
Filter fieldscreated_at, updated_at, fan_platform_id, model_id
Sort fieldscreated_at, updated_at
Return fieldschat_id, platform_chat_id, fan_platform_id, model_id, created_at, updated_at
Opt-in fieldsNamed in fields: message_count, last_message_at, last_message_preview, last_message_from_model
fansEnriched fan profiles with spending and subscription data.
Filter fieldsfan_platform_id, model_id, is_verified, subscribed_on, subscribed_by, can_receive_message, is_blocked, is_restricted, tips_enabled, last_seen, created_at, updated_at, total_spent, messages_spent, tips_spent, subscribe_price, tips_min, tips_max
Sort fieldstotal_spent, messages_spent, tips_spent, subscribe_price, last_seen, created_at, updated_at
Return fieldsfan_id, fan_platform_id, model_id, display_name, username, name, avatar, avatar_thumbs, is_verified, subscribed_on, subscribed_on_duration, subscribed_by, last_seen, can_receive_message, is_blocked, is_restricted, tips_enabled, tips_min, tips_max, subscribe_price, total_spent, messages_spent, tips_spent, posts_spent, subscriptions_spent, created_at, updated_at
Opt-in fieldsNamed in fields: spending_updated_at
message_chunksVector embedding chunks derived from messages. Used for semantic search.
Filter fieldsmessage_id, chunk_type, created_at, model_id, fan_platform_id
Sort fieldscreated_at
Return fieldschunk_id, message_id, chunk_type, text, normalized_text, embedding, chunk_metadata, created_at
Opt-in fieldsNamed in fields: chat_id, model_id, fan_platform_id
message_tagsYour own key/value tags on a sent message (see the tags field on Send Message). Filter on tags.<your key> — the key is whatever you named it, not a fixed field.
Filter fieldsmodel_id, fan_platform_id, tags.<key> (e.g. tags.xpromo_key)
Sort fieldscreated_at
Return fieldsplatform_message_id, model_id, fan_platform_id, tags, created_at
Opt-in fields—
of_daily_statsStored daily earnings from OnlyFans — one row per model per day. See the note below the table list.
Filter fieldsmodel_id, stat_date
Sort fieldsstat_date (default)
Return fieldsmodel_id, platform, stat_date, gross_amount, net_amount, synced_at
Opt-in fields—

Filter Operators

Filters are expressed as an object keyed by field name. Each value is either a direct value (shorthand for eq) or an operator object.

Filter examples
{
  "filters": {
    "fan_platform_id": "553393565",            // shorthand eq
    "created_at": {
      "gte": "2026-01-01T00:00:00Z",
      "lte": "2026-06-30T23:59:59Z"
    },
    "total_spent": { "gte": 50 },
    "is_from_model": { "eq": false },
    "message_text": { "like": "%birthday%" },
    "fan_platform_id": { "in": ["553393565", "123220869", "37098033"] }
  }
}

Filtering message_tags

tags.<key> is a special case: the key after the dot is whatever you named it when you sent the message (see tags on Send Message), not a fixed field — so it can't be listed in the table above. Only eq is supported.
message_tags filter example
{
  "table": "message_tags",
  "filters": {
    "tags.xpromo_key": "summer2026_to_modelB",
    "fan_platform_id": "553393565"
  }
}
OperatorSupported typesDescription
eqstring, integer, float, bool, datetimeExact match. Shorthand: pass a value directly without wrapping in an object.
gteinteger, float, datetimeGreater than or equal to.
lteinteger, float, datetimeLess than or equal to.
gtinteger, float, datetimeStrictly greater than.
ltinteger, float, datetimeStrictly less than.
instringMatch any value in a list. Maximum 500 values.
likestringCase-insensitive substring match. Use % as wildcard: %keyword%.

DSL Error Codes

All DSL validation errors return HTTP 400 with a code field identifying the rejection reason.

Error response shape
{
  "error": "Filter field 'unknown_field' not allowed for table 'messages'",
  "code": "DSL_ERROR"
}
CodeStatusDescription
MISSING_TABLE400The table field was not provided in the request body.
INVALID_TABLE400The requested table is not in the allowed list.
INVALID_FILTERS400The filters field is not a valid object.
INVALID_FIELDS400The fields field is not a valid array.
INVALID_PAGINATION400limit or offset is not an integer.
DSL_ERROR400A filter field, operator, or return field is not allowed. The error message specifies which field caused the rejection.

Org scoping is always enforced

Even if you pass a model_id filter that belongs to another organization, the query will return zero rows — not an error. All results are silently restricted to models in your org before any user-provided filters are applied.

Pagination

The DSL query endpoint uses offset-based pagination.

FieldDescription
totalTotal number of rows matching the filters (before limit/offset). Use this to calculate page count.
limitThe limit applied to this request (echoed back).
offsetThe offset applied to this request (echoed back).
dataArray of result rows for this page.
Fetch all pages
// Page through all results
let offset = 0
const limit = 100
let allData = []

do {
  const res = await fetch(`${BASE_URL}/api/query`, {
    method: "POST",
    headers: { "X-API-Key": apiKey, "Content-Type": "application/json" },
    body: JSON.stringify({ table: "messages", filters: {}, limit, offset }),
  })
  const { data, total } = await res.json()
  allData.push(...data)
  offset += limit
} while (offset < total)

Maximum limit is 1,000

A single request cannot return more than 1,000 rows. Use pagination to retrieve larger datasets.