Skip to content

公式SDK

REST APIとWebSocketストリームをラップするPythonとTypeScriptのクライアント。HTTP呼び出しを自分で書く手間が省けます。

公式SDKは、このサイトで説明しているのと同じRESTエンドポイントと同じWebSocketストリームをカバーしています。どちらも実行時依存のない薄いラッパーで、各メソッドはAPIが送るのと同じJSON形状を返します。

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 エクストラ(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);

ストリーミングにはオプションのピア依存 centrifuge と、BasicまたはProキーが必要です。Freeキーでは、streamToken() の呼び出しがソケットを開く代わりに PlanError(402)をスローします。

npm install centrifuge

エラー

どちらのSDKも、2xx以外のレスポンスごとに型付きエラーを送出します。401 では AuthenticationError402 では PlanError429 では再試行までの待機時間を持つ RateLimitError5xx では ServerError で、いずれも共通の DinoError のサブクラスです。

リソース

Pythonパッケージ: PyPIGitHubのソース。TypeScriptパッケージ: npmGitHubのソースColabノートブックでは、ローカル環境の構築なしにPython SDKを最初から最後まで試せます。

情報提供のためのデータです。投資助言ではありません。取引は各自のvenueアカウントで、自己責任で行ってください。