# Event format: envelope and message fields

Every message is an event: a fixed envelope, a stable id, an increasing revision, and type-specific data.

> Source: https://tokenearly.com/en/developers/events · Docs index: https://tokenearly.com/en/developers/llms.txt · OpenAPI: https://api.tokenearly.com/v1/openapi.json

## Envelope

Every event shares one envelope; the shape of `data` depends on `type`. The stream and REST build events with the same function, so the fields are identical.

| Field | Type | required | Description |
|---|---|---|---|
| `spec_version` | `"1.0"` | ✓ | Event format version. Within a major version fields are only added, never removed or changed. |
| `id` | `string` | ✓ | Stable event id (24 hex characters) shared by every revision; never changes. Ids increase with the time the event was first stored and compare correctly as strings. Also the pagination and resume cursor. |
| `revision` | `integer` | ✓ | Starts at 1 and increases when translations or the original link are filled in, or when the complete version of a post arrives. Deduplicate on (id, revision) and keep the highest. |
| `action` | `"created" \| "updated"` | ✓ | created = first appearance; updated = a newer revision of the same event. |
| `topic` | `string` | ✓ | Topic id in the form <type>.<source>, e.g. announcement.binance; X accounts use their numeric id, e.g. twitter.44196397. |
| `type` | `"announcement" \| "news" \| "signal" \| "twitter"` | ✓ | Message type; decides the shape of `data`. |
| `source` | `object` | ✓ | Source: `id` matches the topic suffix, `name` is the English display name (for X: @handle and display name). (id, name) |
| `published_at` | `integer \| null` | ✓ | When the source published it, Unix seconds. |
| `published_at_ms` | `integer \| null` |  | When the source published it, Unix milliseconds; seconds × 1000 if the source has no milliseconds. |
| `detected_at_ms` | `integer \| null` | ✓ | When Tokenearly received the item, Unix milliseconds; null for a few early records. |
| `data` | `object` | ✓ | Payload; its shape depends on `type` (see each type below). |

## Lifecycle and deduplication

- First appearance: `action = "created"`, `revision = 1`.
- After titles or the original link are filled in (for posts: when the complete version arrives): same `id`, `action = "updated"`, higher `revision`.
- `id` never changes; deduplicate on (id, revision) and keep the highest revision.

**Deduplication**

```python
latest = {}   # event id -> highest revision seen

def handle(ev):
    if latest.get(ev["id"], 0) >= ev["revision"]:
        return                      # duplicate or older revision
    first_time = ev["id"] not in latest
    latest[ev["id"]] = ev["revision"]
    if first_time:
        notify(ev)                  # new to you, whatever its action: after a reconnect a new item
                                    # can already be at revision 2 (action = "updated")
    else:
        update(ev)                  # same event, translations / link filled in
```

## Exchange announcement (type = announcement)

| Field | Type | required | Description |
|---|---|---|---|
| `titles` | `object` | ✓ | Titles in zh / en / ko. A language may be missing until translated; it then arrives as a new revision. (zh, en, ko) |
| `original_lang` | `string` | ✓ | Language the exchange published in: one of zh / en / ko. |
| `translated_langs` | `array<zh \| en \| ko>` | ✓ | Title languages produced by machine translation. Any title not listed here is the exchange's own version: most exchanges publish in one language, some publish official Chinese and English versions, which may arrive in the same push or later (as a new revision that also replaces an earlier machine translation and removes it from this list). Machine translations are empty on the first push and usually filled in within seconds to tens of seconds as a new revision, occasionally minutes later or not at all. |
| `url` | `string \| null` | ✓ | Original announcement on the exchange; for some sources it is filled in shortly after (as a new revision). |
| `exchange_category` | `string \| null` | ✓ | The exchange's own category name, as given (not translated). |
| `listing` | `object` | ✓ | Listing verdict: `is_listing` and `market` (spot / futures / null). Same classifier as the site's listing timeline. (is_listing, market) |
| `symbols` | `array<string>` | ✓ | Token tickers found in the title. |

`data.listing` is the listing verdict and `data.symbols` the tickers found in the title; use them to filter listings. When `is_listing` is false, `market` is always null.

**First push (revision 1): title in the original language only**

```json
{
  "spec_version": "1.0",
  "id": "6b0ff643d0e4e92d84810499",
  "revision": 1,
  "action": "created",
  "topic": "announcement.gate",
  "type": "announcement",
  "source": {
    "id": "gate",
    "name": "Gate.io"
  },
  "published_at": 1796208195,
  "published_at_ms": 1796208195000,
  "detected_at_ms": 1796208195896,
  "data": {
    "titles": {
      "zh": "Gate 已上线 RITUAL 合约交易、杠杆借贷交易、交易机器人、跟单、闪兑、定投功能",
      "en": "Gate Now Supports RITUAL for Futures Trading, Margin Loans, Bots, Copy, Convert, and Auto-Invest"
    },
    "original_lang": "zh",
    "translated_langs": [],
    "url": "https://www.gate.io/article/103112",
    "exchange_category": "listing",
    "listing": {
      "is_listing": true,
      "market": "futures"
    },
    "symbols": []
  }
}
```

**After translation (same id, higher revision): machine-translated titles added**

```json
{
  "spec_version": "1.0",
  "id": "6b0ff643d0e4e92d84810499",
  "revision": 3,
  "action": "updated",
  "topic": "announcement.gate",
  "type": "announcement",
  "source": {
    "id": "gate",
    "name": "Gate.io"
  },
  "published_at": 1796208195,
  "published_at_ms": 1796208195000,
  "detected_at_ms": 1796208195896,
  "data": {
    "titles": {
      "zh": "Gate 已上线 RITUAL 合约交易、杠杆借贷交易、交易机器人、跟单、闪兑、定投功能",
      "en": "Gate Now Supports RITUAL for Futures Trading, Margin Loans, Bots, Copy, Convert, and Auto-Invest",
      "ko": "Gate는 RITUAL 계약 거래, 레버리지 대출 거래, 트레이딩 봇, 팔로우 트레이딩, 스왑, 정기 투자 기능을 출시했습니다."
    },
    "original_lang": "zh",
    "translated_langs": [
      "ko"
    ],
    "url": "https://www.gate.io/article/103112",
    "exchange_category": "listing",
    "listing": {
      "is_listing": true,
      "market": "futures"
    },
    "symbols": []
  }
}
```

## News (type = news)

| Field | Type | required | Description |
|---|---|---|---|
| `titles` | `object` | ✓ | Titles in zh / en / ko. A language may be missing until translated; it then arrives as a new revision. (zh, en, ko) |
| `original_lang` | `string` | ✓ | Language the source published in: one of zh / en / ko. |
| `translated_langs` | `array<zh \| en \| ko>` | ✓ | Title languages produced by machine translation. Any title not listed here is the source's own version: most sources publish in one language, some publish official Chinese and English versions, which may arrive in the same push or later (as a new revision that also replaces an earlier machine translation and removes it from this list). Machine translations are empty on the first push and usually filled in within seconds to tens of seconds as a new revision, occasionally minutes later or not at all. |
| `summary` | `string \| null` | ✓ | Summary as given by the source, in the original language, up to 600 characters; full text is not provided. May be null. |
| `url` | `string \| null` | ✓ | Link to the original article; null for sources that publish flashes without a link. |

`data.summary` is the source's own summary in the original language; full text is not provided. Open `data.url` for the article (some flashes have no link: null).

Flash-style sources have no headline of their own; `titles` is taken from the start of the text and may be cut off with "...".

**First push (revision 1): title in the original language only**

```json
{
  "spec_version": "1.0",
  "id": "6b150bf2d0e4e92d8481211f",
  "revision": 1,
  "action": "created",
  "topic": "news.panews",
  "type": "news",
  "source": {
    "id": "panews",
    "name": "PANews"
  },
  "published_at": 1796541408,
  "published_at_ms": 1796541408000,
  "detected_at_ms": 1796541426000,
  "data": {
    "titles": {
      "zh": "DWF Labs合伙人：比特币已挺过风暴，若Strategy没有崩盘，市场或已触底",
      "en": "DWF Labs Partner: Bitcoin Has Weathered the Storm; If Strategy Hasn't Collapsed, the Market May Have Bottomed"
    },
    "original_lang": "zh",
    "translated_langs": [],
    "summary": "PANews 12月6日消息，DWF Labs 合伙人 Andrei Grachev 发文预测，比特币已经受住这轮市场风暴，如果 Strategy 没有崩盘，那么市场可能已经触底。",
    "url": "https://www.panewslab.com/zh/articles/01a24a36-6342-7407-b95e-475df0dce169"
  }
}
```

**After translation (same id, higher revision): machine-translated titles added**

```json
{
  "spec_version": "1.0",
  "id": "6b150bf2d0e4e92d8481211f",
  "revision": 3,
  "action": "updated",
  "topic": "news.panews",
  "type": "news",
  "source": {
    "id": "panews",
    "name": "PANews"
  },
  "published_at": 1796541408,
  "published_at_ms": 1796541408000,
  "detected_at_ms": 1796541426000,
  "data": {
    "titles": {
      "zh": "DWF Labs合伙人：比特币已挺过风暴，若Strategy没有崩盘，市场或已触底",
      "en": "DWF Labs Partner: Bitcoin Has Weathered the Storm; If Strategy Hasn't Collapsed, the Market May Have Bottomed",
      "ko": "DWF Labs 파트너: 비트코인은 폭풍을 견뎌냈으며, 만약 Strategy가 붕괴되지 않았다면 시장은 이미 바닥에 도달했을 수 있다"
    },
    "original_lang": "zh",
    "translated_langs": [
      "ko"
    ],
    "summary": "PANews 12月6日消息，DWF Labs 合伙人 Andrei Grachev 发文预测，比特币已经受住这轮市场风暴，如果 Strategy 没有崩盘，那么市场可能已经触底。",
    "url": "https://www.panewslab.com/zh/articles/01a24a36-6342-7407-b95e-475df0dce169"
  }
}
```

## Signal (type = signal)

| Field | Type | required | Description |
|---|---|---|---|
| `signal_type` | `string` | ✓ | Signal type, as defined by the source. |
| `level` | `"info" \| "warning" \| "critical"` | ✓ | Severity: info / warning / critical. |
| `titles` | `object` | ✓ | Titles in zh / en / ko; a language may be missing, so fall back to another. (zh, en, ko) |
| `contents` | `object` | ✓ | Summary text in zh / en / ko. (zh, en, ko) |
| `url` | `string \| null` | ✓ | Related link (may be null). |
| `symbols` | `array<string>` | ✓ | Token tickers involved. |
| `tags` | `array<string>` | ✓ | Tags. |

**Example: a signal (real data)**

```json
{
  "spec_version": "1.0",
  "id": "6b055216d0e4e92d8480d1e5",
  "revision": 1,
  "action": "created",
  "topic": "signal.binance_alpha",
  "type": "signal",
  "source": {
    "id": "binance_alpha",
    "name": "Binance Alpha"
  },
  "published_at": 1795510800,
  "published_at_ms": 1795510800000,
  "detected_at_ms": 1795510806000,
  "data": {
    "signal_type": "binance_alpha",
    "level": "info",
    "titles": {
      "zh": "🆕 Binance Alpha 新币上线: SHARE (BSC)",
      "en": "🆕 Binance Alpha New Token: SHARE (BSC)",
      "ko": "🆕 바이낸스 알파 신규 토큰: SHARE (BSC)"
    },
    "contents": {
      "zh": "代币: SHARE (ShareX)\n链: BSC\n价格: $0.0572\n合约: 0xe5e5e1d77125fc910d8f39cdd55b7a24ec69ce34\nAlpha ID: ALPHA_1287\n持有者: 61649\n市值: $56.19M",
      "en": "Token: SHARE (ShareX)\nChain: BSC\nPrice: $0.0572\nContract: 0xe5e5e1d77125fc910d8f39cdd55b7a24ec69ce34\nAlpha ID: ALPHA_1287\nHolders: 61649\nMarket Cap: $56.19M",
      "ko": "토큰: SHARE (ShareX)\n체인: BSC\n가격: $0.0572\n컨트랙트: 0xe5e5e1d77125fc910d8f39cdd55b7a24ec69ce34\nAlpha ID: ALPHA_1287\n보유자: 61649\n시가총액: $56.19M"
    },
    "url": "https://www.binance.com/en/alpha/bsc/0xe5e5e1d77125fc910d8f39cdd55b7a24ec69ce34",
    "symbols": [
      "SHARE"
    ],
    "tags": [
      "new_listing",
      "bsc"
    ]
  }
}
```

## X (Twitter) KOL post (type = twitter)

| Field | Type | required | Description |
|---|---|---|---|
| `kind` | `"tweet" \| "quote" \| "reply" \| "retweet"` | ✓ | Post kind: tweet = original post, quote, reply or retweet. On the first push it is occasionally not final yet (an original later confirmed as a quote, say); the correction arrives as a new revision. |
| `tweet_id` | `string` | ✓ | The post's id on X. For a retweet, reply or quote it is the id of that action itself. |
| `author` | `object` | ✓ | The account that posted: `id` is the numeric X id (same as the topic suffix; unchanged by renames), `screen_name` the handle at the time (without @), `name` the display name. (id, screen_name, name) |
| `text` | `string` | ✓ | Post text as published, not translated. The first push may carry a shortened version (`complete` = false). |
| `lang` | `string \| null` | ✓ | Language code as labelled by X (e.g. en, zh, ja); null when unknown. X also uses a few non-language codes, passed through as is: `zxx` (no text, e.g. media or a link only), `qme` (mentions or emoji only), `qst` (very short text), `art` (emoji only) and similar. |
| `url` | `string \| null` | ✓ | Link to the post on X. |
| `referenced_tweet_id` | `string \| null` | ✓ | Id of the quoted, replied-to or retweeted post; null for an original post. It may be missing on the first push and arrive in a new revision; a few older posts may never have it. |
| `conversation_id` | `string \| null` | ✓ | Reserved: conversation (thread) id. The data source does not provide it at present, so it is always null; to follow a reply chain, walk up through `referenced_tweet_id`. |
| `media` | `array<string>` | ✓ | Image / video URLs, up to 20; may be empty on the first push and filled in by the complete version. |
| `complete` | `boolean` | ✓ | Whether this is the complete version. A post is sometimes pushed first in a shortened form (text may be cut, media and the referenced post missing); the complete version follows with the same id and a higher revision, with this set to true. |

Only posts from a curated list of KOL accounts are included: original posts, quotes, replies and retweets. Profile edits, follows and similar activity are not part of the API. Accounts are added and removed over time; `GET /v1/topics` has the current list.

`data.kind`: `tweet` original post, `quote`, `reply` or `retweet`; for the last three, `data.referenced_tweet_id` is the quoted, replied-to or retweeted post.

A post is sometimes pushed first in a shortened form (`data.complete = false`): the text may be cut, media, the referenced post and the language may be missing, and the kind is occasionally corrected from `tweet` to `quote`. The complete version follows with the same `id` and a higher `revision`.

Posts are given as published, not translated, and have no `titles`. If you subscribe to `*`, parse each `type` separately.

Posts are kept for the last 10 days only: REST queries and stream resumes reach no further back (or your plan's history window, whichever is shorter).

**Example: an X post (real data)**

```json
{
  "spec_version": "1.0",
  "id": "6b150c67e70ade1bb493e0e2",
  "revision": 1,
  "action": "created",
  "topic": "twitter.44196397",
  "type": "twitter",
  "source": {
    "id": "44196397",
    "name": "@elonmusk (Elon Musk)"
  },
  "published_at": 1796541539,
  "published_at_ms": 1796541539136,
  "detected_at_ms": 1796541543941,
  "data": {
    "kind": "quote",
    "tweet_id": "2129475674222317961",
    "author": {
      "id": "44196397",
      "screen_name": "elonmusk",
      "name": "Elon Musk"
    },
    "text": "Yeah",
    "lang": "en",
    "url": "https://x.com/elonmusk/status/2129475674222317961",
    "referenced_tweet_id": "2129371437043483081",
    "conversation_id": null,
    "media": [],
    "complete": true
  }
}
```

## Compatibility

- Within a major version fields are only **added**, never removed, renamed or retyped. Ignore fields you do not know.
- New message types arrive with a new `type`; ignore types you do not handle.
- The full JSON Schema is at [GET /v1/schema](https://tokenearly.com/en/developers/rest/schema).
