SNSUC Market Data API — REST & WebSocket
报价 · K线 · 跨市场价差 · 库存,一套 API Key 全量接入;REST 拉取 + WebSocket 实时推送,5 分钟完成集成
所有请求需在 Header 携带 API Key。Key 在开通订阅后于企业服务后台签发,请勿泄露或写入前端代码。
X-SNSUC-Key: sk_live_9f2c8e7a1b… Accept: application/json
全量报价列表(40+ 品种:能源 / 化工 / 汇率)。
kind 可选,按类别过滤:oil | chem | fxids 可选,逗号分隔的品种 id:ids=methanol,pta,px{
"updated": "2026-07-31T09:30:00+08:00",
"count": 43,
"quotes": [
{
"id": "methanol", "kind": "chem",
"name": { "zh": "甲醇", "en": "Methanol" },
"price": 2639.0, "priceText": "¥2,639/t",
"change": -0.68,
"source": { "zh": "期货 · 主力连续", "en": "Futures · front month" },
"unit": { "zh": "CNY/t · 主力合约", "en": "CNY/t · front month" }
}
]
}单品种报价。{id} 为品种标识(如 px、brent),未收录返回 404。
{
"id": "px", "kind": "chem",
"name": { "zh": "对二甲苯", "en": "Paraxylene (PX)" },
"price": 8196.0, "priceText": "¥8,196/t",
"change": 0.81, "extended": true
}品种 90 日日 K 序列(OHLCV)。
days 可选,返回最近 N 天(1–90),默认 90{
"id": "methanol",
"updated": "2026-07-31T09:30:00+08:00",
"demo": true,
"series": [
{ "t": "2026-07-30", "o": 2651, "h": 2694, "l": 2640, "c": 2687, "v": 52031 },
{ "t": "2026-07-31", "o": 2687, "h": 2697, "l": 2623, "c": 2639, "v": 17206 }
]
}跨市场基差:国内盘面口径 vs 国际 CFR 中国进口平价(甲醇 / PTA / PP / PE / PVC)。
{
"updated": "2026-07-31T09:30:00+08:00",
"demo": true,
"spreads": [
{ "pair": "甲醇 Methanol", "shfe": 2642, "dce": 2625,
"intl": 2700, "basis": 58,
"note": "CFR中国进口完税折算,人民币升水受运费影响" }
]
}重点品种港口 / 社会 / 厂库库存(万吨)及周环比。
{
"updated": "2026-07-31T09:30:00+08:00",
"demo": true,
"items": [
{ "id": "methanol", "name": "甲醇华东港口",
"level": 77.8, "unit": "万吨", "wow": 1.3 }
]
}实时报价推送通道。连接后先收到 snapshot 全量快照,其后按更新推送 tick 增量。可发送 subscribe 消息收窄品种范围。鉴权:连接 URL 携带 ?key=sk_live_…。
{ "op": "subscribe", "ids": ["methanol", "pta", "px"] }// 连接建立后的首帧 { "type": "snapshot", "updated": "…", "quotes": [ /* 全量 */ ] } // 之后的增量推送 { "type": "tick", "id": "methanol", "price": 2641.0, "change": -0.61, "ts": "2026-07-31T09:30:05+08:00" }
Python(requests + websockets)与浏览器/Node JavaScript 最小接入示例。
import requests, asyncio, json, websockets BASE = "https://api.snsuc.com" KEY = {"X-SNSUC-Key": "sk_live_9f2c8e7a1b"} # REST:拉取甲醇最新报价与近30日K线 quote = requests.get(f"{BASE}/api/v1/quotes/methanol", headers=KEY, timeout=10).json() kline = requests.get(f"{BASE}/api/v1/kline/methanol", params={"days": 30}, headers=KEY, timeout=10).json() print(quote["priceText"], len(kline["series"])) # WebSocket:订阅实时推送 async def watch(): async with websockets.connect("wss://api.snsuc.com/ws/quotes?key=sk_live_9f2c8e7a1b") as ws: await ws.send(json.dumps({"op": "subscribe", "ids": ["methanol", "pta"]})) async for msg in ws: print(json.loads(msg)) asyncio.run(watch())
// REST const r = await fetch("https://api.snsuc.com/api/v1/quotes?kind=chem", { headers: { "X-SNSUC-Key": "sk_live_9f2c8e7a1b" } }); const { quotes } = await r.json(); // WebSocket const ws = new WebSocket("wss://api.snsuc.com/ws/quotes?key=sk_live_9f2c8e7a1b"); ws.onopen = () => ws.send(JSON.stringify({ op: "subscribe", ids: ["px", "brent"] })); ws.onmessage = (e) => console.log(JSON.parse(e.data));
后端参考实现为仓库中的 fc/api_server.py:Flask 提供 REST(读取数据中心生成的 market/kline/spreads/inventory JSON),websockets 提供 /ws/quotes 推送,全部端点带 CORS 头。
API 权限按企业服务档位开通:免费档(网页看板 + 限频试用 Key)、专业档(REST 全量 + WS 推送)、企业档(专属数据源、SLA 与技术支持)。
Pricing 查看企业服务档位 → 在企业服务页对比各档位的数据权限、限频与支持范围,开通后即刻签发 API Key。