本页面为机器翻译。英文版本为原文,可能更准确或更及时。 查看英文版

Raw —— 订阅文章

Raw WebSocket 提供了增强版 WebSocket 的一种轻量、精简的替代方案。它实时投递核心文章数据,不包含股票代码匹配、AI 增强或公司实体解析。这使其非常适合您需要快速、基础的文章数据而不希望承担高级处理开销的用例。


文章模型

Raw WebSocket 返回一个仅含核心字段的简化文章模型。不包含任何公司实体或 AI 生成的增强信息。

  • Name
    link
    Type
    string
    Description

    指向完整文章的 URL。

  • Name
    source
    Type
    string
    Description

    来源网站。例如 www.reuters.com

  • Name
    title
    Type
    string
    Description

    文章标题。

  • Name
    summary
    Type
    string
    Description

    文章摘要(如果存在)。可为空。

  • Name
    publishDate
    Type
    Date
    Description

    发布日期,采用 ISO 日期格式。

  • Name
    createdAt
    Type
    Date
    Description

    文章在 finlight 系统中的内部创建日期,采用 ISO 日期格式。

  • Name
    revisedDate
    Type
    Date | null
    Description

    文章在首次发布后最后一次修订的日期。当文章从未修订时为 null。当启用 includeUpdates 且文章已被修订时存在。

  • Name
    isUpdate
    Type
    boolean
    Description

    当本次投递由文章发布后的更新触发时为 true。仅在启用 includeUpdates 时存在。

  • Name
    language
    Type
    string
    Description

    ISO 639-1 语言代码。例如 en | de | fr

  • Name
    images
    Type
    string[]
    Description

    文章中的图片 URL 数组。

  • Name
    countries
    Type
    string[]
    Description

    表示与文章相关的国家/地区的代码数组,采用 ISO 3166-1 alpha-2 格式。例如 ["US", "GB", "DE"]。可为空。

  • Name
    categories
    Type
    string[]
    Description

    文章类别数组。可能的值:markets | economy | business | politics | geopolitics | regulation | technology | energy | commodities | crypto | health | climate | security。可为空。


WEBSOCKET/raw

获取文章

连接后,您只会收到符合您条件的新发布文章。连接时不会发送初始/历史文章。

订阅时,您可以指定以下参数来过滤您接收的文章:

  • Name
    query
    Type
    string
    Description

    用于查找相关文章的搜索查询。对 sourcetitlesummary 字段支持字段级过滤。高级查询

  • Name
    sources
    Type
    string[]
    Description

    按单个或多个来源过滤。例如 ["www.reuters.com", "www.cnbc.com"]。有效值请参见 source 端点。

  • Name
    excludeSources
    Type
    string[]
    Description

    排除单个或多个来源。例如 ["www.reuters.com", "www.cnbc.com"]。有效值请参见 source 端点。

  • Name
    language
    Type
    string
    Description

    按语言过滤(ISO 639-1)。默认为 en,仅返回英语并排除其他语言 —— 参见语言与覆盖范围

  • Name
    includeUpdates
    Type
    boolean
    Description

    启用后,更新的文章会以 isUpdate=truerevisedDate 时间戳重新投递。

Request

WEBSOCKET
/raw
import { FinlightApi } from 'finlight-client'

const client = new FinlightApi(
  {
    apiKey: 'YOUR_API_KEY', // Replace with your API key
  },
  {
    takeover: true, // WebSocket options
  },
)

client.rawWebsocket.connect(
  {
    query: 'Nvidia',
    language: 'en',
    sources: ['www.reuters.com', 'www.cnbc.com'],
  },
  (article) => {
    console.log('New article received:', article)
  },
)

Response

{
  "link": "https://www.example.com/article1",
  "source": "www.example.com",
  "title": "Stock Market Hits New Highs",
  "summary": "A brief summary of the article...",
  "publishDate": "2023-10-01T12:34:56Z",
  "createdAt": "2023-10-01T12:35:10Z",
  "language": "en",
  "images": [
              "https://www.example.com/image1.jpg",
              "https://www.example.com/image2.jpg"
            ],
  "countries": ["US"],
  "categories": ["markets"]
}

Response (includeUpdates: true)

{
  "link": "https://www.example.com/article1",
  "source": "www.example.com",
  "title": "Stock Market Hits New Highs — Updated",
  "summary": "An updated summary of the article...",
  "publishDate": "2023-10-01T12:34:56Z",
  "createdAt": "2023-10-01T12:35:10Z",
  "revisedDate": "2023-10-02T08:00:00Z",
  "isUpdate": true,
  "language": "en",
  "images": [
    "https://www.example.com/image1.jpg"
  ],
  "countries": ["US"],
  "categories": ["markets"]
}

查询字段级过滤

Raw WebSocket 在 query 参数中支持对以下字段进行字段级过滤:

  • source - 按文章来源过滤
  • title - 按文章标题内容过滤
  • summary - 按文章摘要内容过滤

示例:

query=title:Nvidia

返回标题中包含 “Nvidia” 的文章。

query=summary:earnings +title:Tesla

返回摘要中提到 “earnings” 且标题中包含 “Tesla” 的文章。

query=source:www.reuters.com -crypto

返回来自 Reuters 的文章,排除提到 “crypto” 的文章。

有关查询语法的更多详情,请参见高级查询构建指南。


连接行为

  • 认证:使用与增强版 WebSocket 相同的 x-api-key 标头。详情参见 WebSocket 基础
  • Ping/Pong:适用相同的保活机制。定期发送 ping 消息以维持连接。
  • 连接时长:受相同的 2 小时连接限制约束。请相应地实现重连逻辑。
  • 无初始数据:与增强版 WebSocket 不同,连接或重连不会返回匹配的最新文章。连接后只投递新发布的文章。