@dxfeed/api

中文文档
1.6.0发布于 2023/07/31MPL-2.0TypeScriptESM + CJS近 30 天下载 6793

This package provides access to dxFeed streaming data

此软件包已被标记为弃用

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

原始使用文档
文档目录11 节
  1. Install
  2. NodeJS usage
  3. Basic Usage
  4. Import package
  5. Configure & Create connection
  6. Configure & Create subscription
  7. Close subscription
  8. Aggregated API
  9. Get TimeSeries
  10. Subscribe TimeSeries snapshot
  11. Close connection

@dxfeed/api Version

This package provides access to dxFeed streaming data.

Our package is easy to integrate with any modern framework.

Install

npm install @dxfeed/api

NodeJS usage

Install cometd-nodejs-client package

npm install cometd-nodejs-client

and use it in your code

require('cometd-nodejs-client').adapt()
// or
import * as CometdNodejsClient from 'cometd-nodejs-client'
CometdNodejsClient.adapt()

Basic Usage

We have several classes in implementation:

  • Feed (public)
  • Endpoint (private)
  • Subscriptions (private)

The Feed is entry point for configuration and creating subscriptions. Feed manages private classes for connecting and subscribing. The Endpoint is responsible for managing the web socket connection. Subscriptions for managing open subscriptions.

Import package

import Feed from '@dxfeed/api'

Configure & Create connection

Create instance of Feed.

const feed = new Feed()

Provide auth token if needed.

feed.setAuthToken('authToken')

Set web socket address and open connection.

feed.connect('wss://demo.dxfeed.com/webservice/cometd')

Configure & Create subscription

You should specify event types and symbol names.

feed.subscribe<{ value: number }>(
  [EventType.Summary, EventType.Trade] /* event types */,
  ['AEX.IND:TEI'] /* symbols */,
  handleEvent
)

For timed subscription you should also provide time to start subscription from.

For Candle event type along with base symbol, you should specify an aggregation period. You can also set price type. More details: https://kb.dxfeed.com/en/data-access/rest-api.html#candle-symbols

feed.subscribeTimeSeries<{ value: number }>(
  [EventType.Summary, EventType.Trade] /* event types */,
  ['AEX.IND:TEI'] /* symbols */,
  0 /* fromTime */,
  handleEvent
)

Last argument its event handler for process incoming events.

const handleEvent = (event) => {
  /* process event */
}

Close subscription

All subscribe methods return unsubscribe handler, you need to call this method for unsubscribe.

const unsubscribe = feed.subscribe(eventTypes, symbols, handleEvent)

onExit(() => unsubscribe())

Aggregated API

Get TimeSeries

If you want to get TimeSeries events for a given time period, refer to example below.

// inside async function
const events = await feed.getTimeSeries(
  'AAPL{=15m}',
  EventType.Candle,
  fromDate.getTime(),
  toDate.getTime()
)

Subscribe TimeSeries snapshot

If you want to subscribe to TimeSeries events, refer to example below.

const unsubscribe = feed.subscribeTimeSeriesSnapshot('AAPL{=15m}', EventType.Candle, (candles) => {
  // process candles
  chart.setCandles(candles)
})

Close connection

If you need to close the web socket connection

feed.disconnect()

版本与发布记录

@dxfeed/api 共发布 10 个版本,首次发布于 2021/01/12;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.6.0latest2023/07/313 年前
1.5.02023/01/283 年前
1.4.02022/08/254 年前
1.3.02022/08/024 年前
1.2.02022/07/254 年前
1.1.02021/05/245 年前

关于 @dxfeed/api 的常见问题

@dxfeed/api 是什么?

This package provides access to dxFeed streaming data注意:该包已被作者标记为弃用——Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

如何安装 @dxfeed/api?

在项目目录运行 npm install @dxfeed/api,或使用 pnpm add / yarn add / bun add。

@dxfeed/api 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dxfeed/api 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dxfeed/api 可以商用吗?

@dxfeed/api 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@dxfeed/api 的下载量有多少?

根据 npm 官方下载统计,@dxfeed/api 在 2026/10/13 – 2026/11/11 这 30 天内被下载 6,793 次,日均约 226 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dxfeed/api 还在维护吗?

最新版本 1.6.0 发布于 2023/07/31(3 年前);至今共发布 10 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/01/12。作者已将其标记为弃用,新项目建议寻找替代方案。