Merge pull request #3 from 6551Team/br-v2

docs(readme): 添加 WebSocket 实时订阅功能文档
This commit is contained in:
axssbug
2026-03-10 23:50:57 +08:00
committed by GitHub
4 changed files with 460 additions and 0 deletions
+115
View File
@@ -125,6 +125,121 @@ Also supports `config.json` in project root (env vars take precedence):
---
## WebSocket Real-time Subscriptions
**Endpoint**: `wss://ai.6551.io/open/news_wss?token=YOUR_TOKEN`
Subscribe to real-time crypto news updates.
### Subscribe to News
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "news.subscribe",
"params": {
"engineTypes": {
"news": ["Bloomberg", "CoinDesk"],
"onchain": []
},
"coins": ["BTC", "ETH"],
"hasCoin": true
}
}
```
**Response**:
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"success": true,
"filters": {
"engineTypes": {...},
"coins": [...],
"hasCoin": true
}
}
}
```
**Filter Parameters** (all optional):
- `engineTypes`: Object mapping engine type to news type codes
- Key: Engine type (e.g., `"news"`, `"onchain"`, `"listing"`, `"meme"`, `"market"`)
- Value: Array of news type codes (e.g., `["Bloomberg", "CoinDesk"]`)
- Empty array `[]` means all news types under that engine
- Use `list_news_types` tool to get available codes
- `coins`: Array of coin symbols to filter (e.g., `["BTC", "ETH"]`)
- `hasCoin`: Boolean, if true only receive news with coin tags
### Unsubscribe
```json
{
"jsonrpc": "2.0",
"id": 2,
"method": "news.unsubscribe"
}
```
### Server Push - News Update
When new news matches your filters, the server pushes:
```json
{
"jsonrpc": "2.0",
"method": "news.update",
"params": {
"id": "unique-article-id",
"text": "Article title or content",
"newsType": "Bloomberg",
"engineType": "news",
"link": "https://...",
"coins": [
{
"symbol": "BTC",
"market_type": "spot",
"match": "title"
}
],
"ts": 1708473600000
}
}
```
### Server Push - AI News Update
For news with AI analysis (if subscribed):
```json
{
"jsonrpc": "2.0",
"method": "news.ai_update",
"params": {
"id": "unique-article-id",
"text": "Article title",
"newsType": "Bloomberg",
"engineType": "news",
"link": "https://...",
"coins": [...],
"aiRating": {
"score": 85,
"grade": "A",
"signal": "long",
"status": "done",
"summary": "Chinese summary",
"enSummary": "English summary"
},
"ts": 1708473600000
}
}
```
---
## Data Structure
Each article returns:
+115
View File
@@ -125,6 +125,121 @@ $env:OPENNEWS_TOKEN = "<your-token>"
---
## WebSocket リアルタイム購読
**エンドポイント**: `wss://ai.6551.io/open/news_wss?token=YOUR_TOKEN`
リアルタイムの暗号通貨ニュース更新を購読します。
### ニュースを購読
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "news.subscribe",
"params": {
"engineTypes": {
"news": ["Bloomberg", "CoinDesk"],
"onchain": []
},
"coins": ["BTC", "ETH"],
"hasCoin": true
}
}
```
**レスポンス**:
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"success": true,
"filters": {
"engineTypes": {...},
"coins": [...],
"hasCoin": true
}
}
}
```
**フィルタパラメータ**(すべてオプション):
- `engineTypes`: エンジンタイプからニュースタイプコードへのマッピングオブジェクト
- キー:エンジンタイプ(例:`"news"`, `"onchain"`, `"listing"`, `"meme"`, `"market"`
- 値:ニュースタイプコードの配列(例:`["Bloomberg", "CoinDesk"]`
- 空配列 `[]` はそのエンジン下のすべてのニュースタイプを意味します
- `list_news_types` ツールで利用可能なコードを取得できます
- `coins`: 通貨シンボルの配列(例:`["BTC", "ETH"]`
- `hasCoin`: ブール値、true の場合は通貨タグ付きニュースのみ受信
### 購読解除
```json
{
"jsonrpc": "2.0",
"id": 2,
"method": "news.unsubscribe"
}
```
### サーバープッシュ - ニュース更新
フィルタに一致する新しいニュースがあると、サーバーがプッシュ:
```json
{
"jsonrpc": "2.0",
"method": "news.update",
"params": {
"id": "unique-article-id",
"text": "記事のタイトルまたは内容",
"newsType": "Bloomberg",
"engineType": "news",
"link": "https://...",
"coins": [
{
"symbol": "BTC",
"market_type": "spot",
"match": "title"
}
],
"ts": 1708473600000
}
}
```
### サーバープッシュ - AI ニュース更新
AI 分析付きニュース(購読している場合):
```json
{
"jsonrpc": "2.0",
"method": "news.ai_update",
"params": {
"id": "unique-article-id",
"text": "記事のタイトル",
"newsType": "Bloomberg",
"engineType": "news",
"link": "https://...",
"coins": [...],
"aiRating": {
"score": 85,
"grade": "A",
"signal": "long",
"status": "done",
"summary": "中国語の要約",
"enSummary": "English summary"
},
"ts": 1708473600000
}
}
```
---
## データ構造
各記事:
+115
View File
@@ -125,6 +125,121 @@ $env:OPENNEWS_TOKEN = "<your-token>"
---
## WebSocket 실시간 구독
**엔드포인트**: `wss://ai.6551.io/open/news_wss?token=YOUR_TOKEN`
실시간 암호화폐 뉴스 업데이트를 구독합니다.
### 뉴스 구독
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "news.subscribe",
"params": {
"engineTypes": {
"news": ["Bloomberg", "CoinDesk"],
"onchain": []
},
"coins": ["BTC", "ETH"],
"hasCoin": true
}
}
```
**응답**:
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"success": true,
"filters": {
"engineTypes": {...},
"coins": [...],
"hasCoin": true
}
}
}
```
**필터 매개변수** (모두 선택사항):
- `engineTypes`: 엔진 유형에서 뉴스 유형 코드로의 매핑 객체
- 키: 엔진 유형 (예: `"news"`, `"onchain"`, `"listing"`, `"meme"`, `"market"`)
- 값: 뉴스 유형 코드 배열 (예: `["Bloomberg", "CoinDesk"]`)
- 빈 배열 `[]`은 해당 엔진의 모든 뉴스 유형을 의미
- `list_news_types` 도구로 사용 가능한 코드 확인
- `coins`: 코인 심볼 배열 (예: `["BTC", "ETH"]`)
- `hasCoin`: 불리언, true일 경우 코인 태그가 있는 뉴스만 수신
### 구독 취소
```json
{
"jsonrpc": "2.0",
"id": 2,
"method": "news.unsubscribe"
}
```
### 서버 푸시 - 뉴스 업데이트
필터와 일치하는 새 뉴스가 있으면 서버가 푸시:
```json
{
"jsonrpc": "2.0",
"method": "news.update",
"params": {
"id": "unique-article-id",
"text": "기사 제목 또는 내용",
"newsType": "Bloomberg",
"engineType": "news",
"link": "https://...",
"coins": [
{
"symbol": "BTC",
"market_type": "spot",
"match": "title"
}
],
"ts": 1708473600000
}
}
```
### 서버 푸시 - AI 뉴스 업데이트
AI 분석이 있는 뉴스 (구독한 경우):
```json
{
"jsonrpc": "2.0",
"method": "news.ai_update",
"params": {
"id": "unique-article-id",
"text": "기사 제목",
"newsType": "Bloomberg",
"engineType": "news",
"link": "https://...",
"coins": [...],
"aiRating": {
"score": 85,
"grade": "A",
"signal": "long",
"status": "done",
"summary": "중국어 요약",
"enSummary": "English summary"
},
"ts": 1708473600000
}
}
```
---
## 데이터 구조
각 기사:
+115
View File
@@ -125,6 +125,121 @@ $env:OPENNEWS_TOKEN = "<your-token>"
---
## WebSocket 实时订阅
**端点**: `wss://ai.6551.io/open/news_wss?token=YOUR_TOKEN`
订阅实时加密货币新闻更新。
### 订阅新闻
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "news.subscribe",
"params": {
"engineTypes": {
"news": ["Bloomberg", "CoinDesk"],
"onchain": []
},
"coins": ["BTC", "ETH"],
"hasCoin": true
}
}
```
**响应**:
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"success": true,
"filters": {
"engineTypes": {...},
"coins": [...],
"hasCoin": true
}
}
}
```
**过滤参数**(全部可选):
- `engineTypes`: 引擎类型到新闻类型代码的映射对象
- 键:引擎类型(如 `"news"`, `"onchain"`, `"listing"`, `"meme"`, `"market"`
- 值:新闻类型代码数组(如 `["Bloomberg", "CoinDesk"]`
- 空数组 `[]` 表示该引擎下的所有新闻类型
- 使用 `list_news_types` 工具获取可用代码
- `coins`: 币种符号数组(如 `["BTC", "ETH"]`
- `hasCoin`: 布尔值,为 true 时只接收带币种标签的新闻
### 取消订阅
```json
{
"jsonrpc": "2.0",
"id": 2,
"method": "news.unsubscribe"
}
```
### 服务器推送 - 新闻更新
当有新闻匹配你的过滤条件时,服务器推送:
```json
{
"jsonrpc": "2.0",
"method": "news.update",
"params": {
"id": "unique-article-id",
"text": "文章标题或内容",
"newsType": "Bloomberg",
"engineType": "news",
"link": "https://...",
"coins": [
{
"symbol": "BTC",
"market_type": "spot",
"match": "title"
}
],
"ts": 1708473600000
}
}
```
### 服务器推送 - AI 新闻更新
对于有 AI 分析的新闻(如果订阅):
```json
{
"jsonrpc": "2.0",
"method": "news.ai_update",
"params": {
"id": "unique-article-id",
"text": "文章标题",
"newsType": "Bloomberg",
"engineType": "news",
"link": "https://...",
"coins": [...],
"aiRating": {
"score": 85,
"grade": "A",
"signal": "long",
"status": "done",
"summary": "中文摘要",
"enSummary": "English summary"
},
"ts": 1708473600000
}
}
```
---
## 数据结构
每篇文章返回: