Skip to Content
数据接口库快速开始

基础使用

Signal Feed 提供 RESTful API 接口,通过 HTTP 请求即可获取金融数据。

认证方式

所有 API 接口都需要通过 Bearer Token 认证:

Authorization: Bearer YOUR_API_TOKEN

基础请求示例

JavaScript/Node.js

const API_TOKEN = 'your_api_token'; const BASE_URL = 'http://localhost:4000/api/v1'; // 基础请求函数 async function apiRequest(endpoint, options = {}) { const response = await fetch(`${BASE_URL}${endpoint}`, { headers: { 'Authorization': `Bearer ${API_TOKEN}`, 'Content-Type': 'application/json', ...options.headers }, ...options }); if (!response.ok) { const error = await response.json(); throw new Error(`API 错误: ${error.message}`); } return response.json(); } // 获取A股股票详情 async function getStockDetail(code) { return apiRequest(`/stock/detail/${code}`); } // 获取ETF列表 async function getETFList() { return apiRequest('/fund/all-etf-list'); } // 获取市场指数 async function getMarketIndices() { return apiRequest('/market/indices'); }

Python

import requests API_TOKEN = 'your_api_token' BASE_URL = 'http://localhost:4000/api/v1' headers = { 'Authorization': f'Bearer {API_TOKEN}', 'Content-Type': 'application/json' } # 获取股票详情 def get_stock_detail(code): response = requests.get( f'{BASE_URL}/stock/detail/{code}', headers=headers ) response.raise_for_status() return response.json() # 获取基金列表 def get_etf_list(): response = requests.get( f'{BASE_URL}/fund/all-etf-list', headers=headers ) response.raise_for_status() return response.json()

响应格式

所有接口统一返回以下格式:

{ "success": true, "data": { // 具体数据内容 }, "message": "可选的消息" }

使用示例

获取股票数据(A股)

// 获取A股股票列表 const stocks = await apiRequest('/stock/list?codes=000001,600519'); // 获取A股股票K线 const kline = await apiRequest('/stock/kline?code=000001&period=day&fqt=pre'); // 获取A股股票财务指标 const financial = await apiRequest('/stock/indicator/financial/000001');

获取ETF基金数据

// 获取ETF基金列表 const etfList = await apiRequest('/fund/all-etf-list'); // 获取ETF基金详情 const etfDetail = await apiRequest('/fund/detail/159919'); // 获取ETF基金持仓 const holdings = await apiRequest('/fund/holdings/159919');

获取宏观数据

// 获取PMI数据 const pmi = await apiRequest('/macro/pmi?page=1&pageSize=20'); // 获取CPI数据 const cpi = await apiRequest('/macro/cpi/series'); // 获取GDP数据 const gdp = await apiRequest('/macro/gdp/series');

获取市场数据

// 获取大盘指数 const indices = await apiRequest('/market/indices'); // 获取资金流向 const flow = await apiRequest('/market/flow?type=1'); // 获取市场热力图 const hotmap = await apiRequest('/market/hotmap');

获取新闻数据

// 获取市场概览 const overview = await apiRequest('/news/overview'); // 获取题材库列表 const topics = await apiRequest('/news/topic/library/list'); // 获取快讯要闻 const feed = await apiRequest('/news/feed?cursor=');

错误处理

try { const data = await apiRequest('/stock/detail/000001'); console.log('数据:', data); } catch (error) { console.error('请求失败:', error.message); // 处理错误 }

下一步

Last updated on