跳到主要内容

OpenBB Workspace 集成 API

/openbb 路由从你自己的实例为 OpenBB Workspace 的组件提供数据。每个路由调用其所适配的 Fonrex 路由,并将响应重塑为 OpenBB 所需的三种格式之一:

  • metric:指标卡片列表 [{"label": "...", "value": ..., "delta": ...}]
  • chart:Plotly 图形 {"data": [...], "layout": {...}}
  • table:供 AgGrid 使用的扁平行列表 [{...}, {...}]

配置方法见 OpenBB Workspace 指南。

认证​

路由密钥
GET /widgets.json, GET /apps.json无需密钥——OpenBB 在配置密钥之前就会获取它们
GET /openbb/...必需,放在 X-API-KEY 请求头中(或 Authorization: Bearer)

只读密钥(FONREX_READ_ONLY_API_KEYS)即可使用所有组件。CORS 接受 OPENBB_ALLOWED_ORIGIN 中的来源(默认为 https://pro.openbb.co)。

发现文件​

  • GET /widgets.json——19 个组件:每个组件的名称、类别、类型、路由和参数(integrations/openbb/widgets.json)。
  • GET /apps.json——两个预先组装好的仪表板:Fonrex — EU Markets 和 Fonrex — Screener & Macro(integrations/openbb/apps.json)。

路由​

组件类型路由适配自
fonrex_quotemetricGET /openbb/quote/{ticker}/quote/{ticker}
fonrex_macro_ratesmetricGET /openbb/macro/rates/macro/rates
fonrex_eodchartGET /openbb/eod/{ticker}(period 默认为 1y)/eod/{ticker}
fonrex_historychartGET /openbb/ticker/{symbol}/history/ticker/{symbol}/history
fonrex_technicalchartGET /openbb/technical/{ticker}/technical/{ticker}
fonrex_technical_multichartGET /openbb/technical/{ticker}/multi/technical/{ticker}/multi
fonrex_technical_chartchartGET /openbb/technical/{ticker}/chart/technical/{ticker}/chart
fonrex_fundamentalstableGET /openbb/fundamental/fundamental
fonrex_fundamentals_deeptableGET /openbb/fundamental/deep/fundamental/deep
fonrex_quotes_batchtableGET /openbb/quotes/quotes
fonrex_screenertableGET /openbb/technical/screen/technical/screen
fonrex_newstableGET /openbb/news/{ticker}/news/{ticker}
fonrex_news_feedtableGET /openbb/news/feed/news/feed
fonrex_dcftableGET /openbb/dcf/{ticker}/dcf/{ticker}
fonrex_dcf_comparetableGET /openbb/dcf/{ticker}/compare/dcf/{ticker}/compare
fonrex_dcf_sensitivitytableGET /openbb/dcf/{ticker}/sensitivity/dcf/{ticker}/sensitivity
fonrex_insider_transactionstableGET /openbb/insider-transactions/{ticker}/insider-transactions/{ticker}
fonrex_etf_detailstableGET /openbb/etf/{isin}/details/etf/{isin}/details
fonrex_index_constituentstableGET /openbb/index/{index_name}/constituents/index/{index_name}/constituents

每个路由接受其所适配路由的参数(参见相应的 API 参考页面),但有少数差异:/openbb/fundamental 没有 fmt;/openbb/technical/{ticker}/multi 没有 include_ohlcv,默认为 sma_20,ema_50,rsi_14;/openbb/technical/{ticker}/chart 默认为 sma_20,rsi_14;/openbb/news/feed 默认返回 20 篇文章。

GET /openbb/quote/{ticker} 从不启动实时数据流:当该代码已通过 POST /realtime/subscribe 订阅时,报价为实时报价,否则为 Yahoo Finance 的延迟价格。

示例​

curl -s -H "X-API-KEY: $FONREX_API_KEY" "http://localhost:5000/openbb/quote/AIR.PA"
[
{ "label": "AIR.PA Price", "value": 154.6, "delta": 0.13 },
{ "label": "Change", "value": "+0.20", "delta": "+0.13%" },
{ "label": "Previous Close", "value": 154.4, "delta": null },
{ "label": "Day High", "value": 155.48, "delta": null },
{ "label": "Day Low", "value": 155.1, "delta": null },
{ "label": "Volume", "value": 18250, "delta": null }
]

此示例为 Yahoo Finance 的延迟报价。没有值的卡片(无前收盘价、无成交量……)会被省略。