Skip to content

官方 SDK

封装了 REST API 与 WebSocket 数据流的 Python 与 TypeScript 客户端,免去手写 HTTP 调用的麻烦。

官方 SDK 覆盖本站文档中记录的同一批 REST 端点和同一条 WebSocket 数据流。两者都是无运行时依赖的轻量封装,每个方法返回的 JSON 结构与 API 本身一致。

Python

PyPI 上的包名是 dino-markets。需要 Python 3.9 或更高版本。

pip install dino-markets
from dino_markets import Dino

client = Dino()  # reads DINO_API_KEY, or pass api_key= directly

markets = client.markets(sport="baseball")
arbs = client.find_arbitrage(sport="baseball", limit=20)
history = client.history(markets["markets"][0]["id"])

流式推送需要 stream extra(附带安装 centrifuge-python)和 Basic 或 Pro 密钥。使用 Free 密钥时,stream_token() 会在打开任何连接之前抛出 PlanError(402)。

pip install "dino-markets[stream]"

TypeScript

npm 上的包名是 dino-markets。构建于原生 fetch API 之上,因此可在 Node 18+、Deno、Bun 以及浏览器中运行,无需打包器 polyfill。

npm install dino-markets
import { Dino } from "dino-markets";

const dino = new Dino(); // reads DINO_API_KEY, or pass { apiKey: "..." }

const { markets } = await dino.markets({ sport: "baseball" });
const arbs = await dino.findArbitrage({ sport: "baseball", limit: 20 });
const history = await dino.history(markets[0].id);

流式推送需要可选的 peer 依赖 centrifuge 和 Basic 或 Pro 密钥。使用 Free 密钥时,streamToken() 调用不会打开连接,而是抛出 PlanError(402)。

npm install centrifuge

错误处理

两个 SDK 都会为每个非 2xx 响应抛出带类型的错误:401 对应 AuthenticationError402 对应 PlanError429 对应携带重试等待时间的 RateLimitError5xx 对应 ServerError,全部继承自同一个 DinoError

相关资源

Python 包:PyPI 页面GitHub 源码。TypeScript 包:npm 页面GitHub 源码Colab 笔记本带你完整走一遍 Python SDK,无需在本地安装任何东西。

仅供参考数据,不构成投资建议。你在各自平台的账户上自行交易,风险自负。