# 이벤트 조회

토픽별 과거 이벤트 조회. 커서 페이지네이션과 따라잡기를 지원합니다.

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

`GET https://api.tokenearly.com/v1/events`

기본은 최신 이벤트부터 반환합니다. `after`를 주면 오래된 순으로 바뀌어 해당 이벤트 이후를 모두 받으며, 연결이 끊긴 뒤 따라잡는 용도입니다. `before`는 더 과거로 넘깁니다. `has_more`가 true이면 `next_cursor`를 `cursor_param`이 가리키는 파라미터에 넣어 계속 요청하세요. 응답의 `access`는 요청한 토픽 중 권한이 있는 것(granted), 없는 것(denied), 존재하지 않는 것(unknown)을 알려 줍니다. 조회 가능한 기간은 플랜의 기록 보관 일수로 정해집니다.

**API 키 필요**

## 파라미터

| 파라미터 | 위치 | 타입 | 필수 | 설명 |
|---|---|---|---|---|
| `topics` | query | string |  | 쉼표로 구분하며 자유롭게 조합할 수 있습니다(예: `announcement.binance,news.*`). 각 항목은 토픽 또는 패턴: `announcement.binance`, `announcement.*`, `news.*`, `signal.*`, `twitter.*`, `*`. 생략하면 키가 읽을 수 있는 모든 토픽. |
| `after` | query | string |  | 이 이벤트 ID보다 새로운 이벤트를 오래된 순으로 반환합니다. 연결이 끊긴 뒤 따라잡을 때 씁니다. |
| `before` | query | string |  | 이 이벤트 ID보다 오래된 이벤트를 최신순으로 반환합니다. 과거로 페이지를 넘길 때 씁니다. |
| `updated_after` | query | integer |  | 이 Unix 시간(초) 이후 새 리비전이 생긴 이벤트(이벤트 자체는 더 오래될 수 있음)를 이벤트 ID 순으로 반환합니다. 오프라인 동안 놓친 기존 이벤트의 업데이트를 받을 때 씁니다. 페이지를 넘길 때는 updated_after는 그대로 두고 이전 next_cursor를 after로 넘기세요. before와 함께 쓸 수 없습니다. 생략하거나 0을 넘기면 사용하지 않는 것으로 봅니다(일반 목록, 최신순). |
| `limit` | query | integer |  | 페이지 크기 1–200, 기본 50. |
| `listings_only` | query | boolean |  | true로 설정하면 상장으로 판정된 거래소 공지(`data.listing.is_listing = true`)만 반환하며 다른 유형의 토픽은 반환하지 않습니다. `after` / `before` / `updated_after`와 함께 쓸 수 있습니다. 판정 결과로 거르기 때문에 한 페이지가 `limit`보다 적어도 `has_more`가 true일 수 있으니 `has_more`가 false가 될 때까지 `next_cursor`로 계속 넘기세요. |

## 요청 예시

**cURL**

```bash
curl "https://api.tokenearly.com/v1/events?topics=announcement.*,news.odaily&limit=5" \
  -H "Authorization: Bearer $TOKENEARLY_API_KEY"
```

**Python**

```python
import os, requests

resp = requests.get(
    "https://api.tokenearly.com/v1/events?topics=announcement.*,news.odaily&limit=5",
    headers={"Authorization": f"Bearer {os.environ['TOKENEARLY_API_KEY']}"},
    timeout=10,
)
resp.raise_for_status()
print(resp.json())
```

**Node.js**

```javascript
// Node 18+ (built-in fetch)
async function main() {
  const resp = await fetch("https://api.tokenearly.com/v1/events?topics=announcement.*,news.odaily&limit=5", {
    headers: { Authorization: `Bearer ${process.env.TOKENEARLY_API_KEY}` },
  });
  const body = await resp.json();
  if (!resp.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
  console.log(body);
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
```

**Go**

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
)

func main() {
	req, _ := http.NewRequest("GET", "https://api.tokenearly.com/v1/events?topics=announcement.*,news.odaily&limit=5", nil)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("TOKENEARLY_API_KEY"))
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(resp.Status, string(body))
}
```

## 응답 예시

```json
{
  "events": [
    {
      "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
      }
    },
    {
      "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"
      }
    },
    {
      "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": []
      }
    },
    {
      "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"
        ]
      }
    }
  ],
  "has_more": true,
  "next_cursor": "6b055216d0e4e92d8480d1e5",
  "cursor_param": "before",
  "access": {
    "granted": [
      "announcement.gate",
      "news.panews",
      "signal.binance_alpha",
      "twitter.44196397"
    ],
    "denied": [],
    "unknown": []
  }
}
```

## 오류

| 코드 | HTTP | 설명 |
|---|---|---|
| `missing_api_key` | 401 | 키가 없습니다. `Authorization: Bearer <키>`를 쓰세요. |
| `invalid_api_key` | 401 | 키가 없거나 재설정 또는 폐기되었습니다. |
| `key_expired` | 401 | 체험 키가 만료되었습니다. 새 체험 키를 신청하거나 구독 후 정식 키를 만드세요. |
| `plan_required` | 403 | 현재 플랜에 개발자 API(또는 해당 기능)가 없습니다. |
| `ip_not_allowed` | 403 | 키에 IP 허용 목록이 설정되어 있고 요청 IP가 목록에 없습니다. |
| `invalid_cursor` | 400 | after / before가 올바른 ID가 아니거나(이벤트는 이벤트 ID, 내 알림은 내 알림 ID) 둘 다 보냈거나, (이벤트만) updated_after와 before를 함께 썼습니다. |
| `invalid_parameter` | 400 | 파라미터 타입이나 값이 잘못되었습니다(예: limit 범위 초과). |
| `rate_limited` | 429 | 이 키의 요청 빈도를 넘었습니다(REST와 MCP 합산, 간격은 `/v1/me`의 `limits.rest_interval_seconds`). Retry-After 초만큼 기다린 뒤 다시 시도하세요. |

## 조회할 수 있는 토픽

`topics`에는 아래 표의 토픽 ID를 넣거나 `announcement.*`, `news.*`, `signal.*`, `twitter.*`, `*` 패턴을 씁니다. 읽기 권한은 플랜에 따르며 응답의 `access`가 토픽별로 알려 줍니다: `granted`(권한 있음, 포함됨), `denied`(권한 없음), `unknown`(없는 토픽).

**예시: topics=announcement.binance,announcement.upbit,announcement.nope**

```json
{
  "access": {
    "granted": [
      "announcement.binance"
    ],
    "denied": [
      "announcement.upbit"
    ],
    "unknown": [
      "announcement.nope"
    ]
  }
}
```

| 토픽 ID | 이름 | 유형 |
|---|---|---|
| `announcement.binance` | 바이낸스 | 거래소 공지 |
| `announcement.okx` | OKX | 거래소 공지 |
| `announcement.mexc` | MEXC | 거래소 공지 |
| `announcement.bitget` | Bitget | 거래소 공지 |
| `announcement.gate` | Gate.io | 거래소 공지 |
| `announcement.huobi` | 후오비 | 거래소 공지 |
| `announcement.bybit` | Bybit | 거래소 공지 |
| `announcement.kucoin` | KuCoin | 거래소 공지 |
| `announcement.upbit` | 업비트 | 거래소 공지 |
| `announcement.bithumb` | 빗썸 | 거래소 공지 |
| `news.odaily` | Odaily | 뉴스 |
| `news.jinse` | 진세 파이낸스 | 뉴스 |
| `news.theblockbeats` | 더블록비츠 | 뉴스 |
| `news.foresight` | Foresight News | 뉴스 |
| `news.panews` | PANews | 뉴스 |
| `news.coinmarketcap` | CoinMarketCap | 뉴스 |
| `news.wallstreetcn` | WallStreetCN | 뉴스 |
| `news.theblock` | The Block | 뉴스 |
| `signal.binance_alpha` | Binance Alpha | 시그널 |
| `twitter.44196397` | @elonmusk (Elon Musk) | X(트위터) KOL 게시물 |
| `twitter.902926941413453824` | @cz_binance (CZ 🔶 BNB) | X(트위터) KOL 게시물 |
| `twitter.574032254` | @coinbase (Coinbase 🛡️) | X(트위터) KOL 게시물 |
| `twitter.1422537905885442055` | @CoinbaseAssets (Coinbase Assets 🛡️) | X(트위터) KOL 게시물 |
| `twitter.720487892670410753` | @CoinbaseMarkets (Coinbase Markets 🛡️) | X(트위터) KOL 게시물 |
| `twitter.877807935493033984` | @binance (Binance) | X(트위터) KOL 게시물 |
| `twitter.295218901` | @VitalikButerin (vitalik.eth) | X(트위터) KOL 게시물 |
| `twitter.1003840309166366721` | @heyibinance (Yi He) | X(트위터) KOL 게시물 |
| `twitter.902839045356744704` | @justinsuntron (H.E. Justin Sun 👨‍🚀 🌞) | X(트위터) KOL 게시물 |
| `twitter.900935123968737281` | @hebi555 (何币) | X(트위터) KOL 게시물 |
| `twitter.1403881130802225152` | @BTCdayu (大宇) | X(트위터) KOL 게시물 |
| `twitter.2985599460` | @star_okx (Star_OKX) | X(트위터) KOL 게시물 |
| `twitter.1533037218444476416` | @xincctnnq (币圈女菩萨｜Pizza披萨🍕) | X(트위터) KOL 게시물 |
| `twitter.25073877` | @realDonaldTrump (Donald J. Trump) | X(트위터) KOL 게시물 |
| `twitter.1686901686185721857` | @TrumpDailyPosts (Commentary Trump Daily Posts) | X(트위터) KOL 게시물 |
| `twitter.20736511` | @nayibbukele (Nayib Bukele) | X(트위터) KOL 게시물 |
| `twitter.1844002277218242560` | @Plasma | X(트위터) KOL 게시물 |
| `twitter.2414580907` | @pauliepunt (Paul) | X(트위터) KOL 게시물 |
| `twitter.867617849208037377` | @okx (OKX) | X(트위터) KOL 게시물 |
| `twitter.1138033434` | @Rewkang (Andrew Kang) | X(트위터) KOL 게시물 |
| `twitter.1789908971953799168` | @Aster_DEX (Aster 🥷) | X(트위터) KOL 게시물 |
| `twitter.1948234340556763136` | @zakk_okx (Zakk 🟪 OKX AI) | X(트위터) KOL 게시물 |
| `twitter.357312062` | @Bitcoin | X(트위터) KOL 게시물 |
| `twitter.973261472` | @blknoiz06 (Ansem 🐂🀄️) | X(트위터) KOL 게시물 |
| `twitter.132749200` | @OxSunNFT (0xSun ❤️ Memecoin) | X(트위터) KOL 게시물 |
| `twitter.844304603336232960` | @MustStopMurad (Murad 💹🧲) | X(트위터) KOL 게시물 |
| `twitter.1195728139898376193` | @0xcryptowizard (0xWizard) | X(트위터) KOL 게시물 |
| `twitter.992590209752629249` | @notEezzy (Eezzy 🧸) | X(트위터) KOL 게시물 |
| `twitter.1800348208461205504` | @xiaomucrypto (新股神白毛股神) | X(트위터) KOL 게시물 |
| `twitter.16228398` | @mcuban (Mark Cuban) | X(트위터) KOL 게시물 |
| `twitter.1189381231198134272` | @CookerFlips (Cooker.hl \| 版本之子 \| (Theo Arc)) | X(트위터) KOL 게시물 |
| `twitter.1279711663264894977` | @DekuKing1 (0x易经(刘彻版)) | X(트위터) KOL 게시물 |
| `twitter.725984371946082304` | @XXAntiWar (XX) | X(트위터) KOL 게시물 |
| `twitter.1462727797135216641` | @lookonchain (Lookonchain) | X(트위터) KOL 게시물 |
| `twitter.1466673394649559040` | @huahuayjy (花花) | X(트위터) KOL 게시물 |
| `twitter.1401718840535379970` | @hellosuoha (梭教授说) | X(트위터) KOL 게시물 |
| `twitter.1453603581932687368` | @laofeiyyds (比特币老肥.btc（敏感肥）) | X(트위터) KOL 게시물 |
| `twitter.1852674305517342720` | @aixbt_agent (aixbt) | X(트위터) KOL 게시물 |
| `twitter.1279918106111025153` | @assetdash (Dash News) | X(트위터) KOL 게시물 |
| `twitter.169686021` | @kanyewest (ye) | X(트위터) KOL 게시물 |
| `twitter.1483495485889564674` | @bwenews (方程式新闻 BWEnews 🏎️) | X(트위터) KOL 게시물 |
| `twitter.1052454006537314306` | @BNBCHAIN (BNB Chain) | X(트위터) KOL 게시물 |
| `twitter.1451036242431262720` | @binancezh (币安Binance华语) | X(트위터) KOL 게시물 |
| `twitter.1940360837547565056` | @aleabitoreddit (Serenity) | X(트위터) KOL 게시물 |

모든 토픽의 권한을 한 번에 보려면 키와 함께 [GET /v1/topics](https://tokenearly.com/ko/developers/rest/topics)를 호출하세요. 토픽마다 `accessible` 필드가 붙습니다.

## 끊긴 뒤 따라잡기

두 단계입니다: `after=<마지막 이벤트 id>`로 `has_more`가 false가 될 때까지 새 이벤트를 받고, `updated_after=<끊긴 시각>`으로 그동안 새 리비전이 생긴 기존 이벤트를 받습니다(`after`는 이벤트 ID 순으로만 진행해 기존 이벤트의 업데이트는 주지 않습니다). 그다음 스트림에 다시 연결하세요.

```python
import os, time, requests

KEY = os.environ["TOKENEARLY_API_KEY"]
API = "https://api.tokenearly.com/v1/events"
TOPICS = "announcement.*,news.*,signal.*,twitter.*"
H = {"Authorization": f"Bearer {KEY}"}

def get(params):
    while True:
        r = requests.get(API, params=dict(params, topics=TOPICS, limit=200), headers=H, timeout=10)
        if r.status_code == 429:
            time.sleep(int(r.headers.get("Retry-After", "3")))   # whole seconds
            continue
        r.raise_for_status()
        time.sleep(int(r.headers.get("X-RateLimit-Reset", "3")))   # respect the per-key interval
        return r.json()

cursor = load_last_event_id()          # the last event id you stored (None on the first run)
offline_since = load_last_seen_time()  # Unix seconds when you last had a live connection (0 on the first run)

# First run: nothing to catch up. Just connect to the stream and start storing ids and times.
if cursor and offline_since:
    # 1) new events after the cursor (oldest first, `cursor_param` is "after")
    while True:
        page = get({"after": cursor})
        for ev in page["events"]:
            handle(ev)
            cursor = ev["id"]
        if not page["has_more"]:
            break

    # 2) older events that got a new revision while you were away
    params = {"updated_after": offline_since}
    while True:
        page = get(params)
        for ev in page["events"]:
            handle(ev)                 # same (id, revision) dedupe as for live events
        if not page["has_more"]:
            break
        # always pass next_cursor under the name the response gives in `cursor_param`
        params = {"updated_after": offline_since, page["cursor_param"]: page["next_cursor"]}
    save_last_event_id(cursor)
```
