5분 설정
빠른 시작
5분 안에 PolyTest API를 시작하세요. 인증하고, 마켓을 가져오고, 스냅샷을 조회하세요. 여기서 바로 실행해 볼 수 있는 예시가 준비되어 있습니다.
1인증
2마켓 가져오기
3스냅샷 가져오기
1단계
인증
3일 무료 체험을 시작하고 대시보드에서 API 키를 생성하세요. 모든 요청은 X-API-Key 헤더로 인증됩니다.
API 키
키 받기키는 이 브라우저에서 보내는 실시간 요청에만 사용되며, 저장되거나 저희 서버로 전송되지 않습니다.
키 교체: API 키는 90일마다 교체하는 것을 권장합니다.
// npm install @polytest/sdk
// export POLYTEST_KEY="pt_live_your_key_here"
import { polytest } from "@polytest/sdk"
const api = polytest() // reads POLYTEST_KEY
const limits = await api.limits()
console.log(limits.tier) // "builder"# Copy your key from the dashboard
export POLYTEST_KEY="pt_live_your_key_here"
# Test it with a simple request
curl -H "X-API-Key: $POLYTEST_KEY" \
"https://api.polytest.io/api/v1/limits"import requests
API_KEY = "pt_live_your_key_here"
headers = {"X-API-Key": API_KEY}
# Verify your key works
res = requests.get("https://api.polytest.io/api/v1/limits", headers=headers)
print(res.json()) # {"tier": "builder", "rate_limits": {...}, ...}const API_KEY = "pt_live_your_key_here";
const res = await fetch("https://api.polytest.io/api/v1/limits", {
headers: { "X-API-Key": API_KEY }
});
const data = await res.json();
console.log(data); // { tier: "builder", rate_limits: {...}, ... }2단계
마켓 가져오기
이용 가능한 모든 예측 시장을 조회합니다. 코인(BTC, ETH, SOL, 그리고 곧 지원될 XRP, DOGE, BNB)과 마켓 타임프레임으로 필터링할 수 있습니다. 최신순으로 정렬된 페이지네이션 결과를 반환합니다.
import { polytest } from "@polytest/sdk"
const api = polytest()
const page = await api.markets({ market_type: "5m", coin: "btc", limit: 3 })
console.log(page.total)
for (const market of page.items) console.log(market.slug, market.winner)curl -H "X-API-Key: $POLYTEST_KEY" \
"https://api.polytest.io/api/v1/markets?coin=btc&market_type=5m&limit=3"res = requests.get(
"https://api.polytest.io/api/v1/markets",
headers={"X-API-Key": API_KEY},
params={"coin": "btc", "market_type": "5m", "limit": 3}
)
data = res.json()
print(f"{data['total']} markets available")
for m in data["markets"]:
print(m["slug"], m["winner"])const res = await fetch(
"https://api.polytest.io/api/v1/markets?coin=btc&market_type=5m&limit=3",
{ headers: { "X-API-Key": API_KEY } }
);
const { markets, total } = await res.json();
console.log(`${total} markets available`);3단계
스냅샷 가져오기
모든 마켓의 과거 가격 스냅샷을 가져옵니다. 각 스냅샷에는 자산 가격, Up/Down 결과 확률, 선택적 오더북 깊이가 포함됩니다. 스냅샷은 초당 8회 수집됩니다.
import { polytest } from "@polytest/sdk"
const api = polytest()
const markets = await api.markets({ market_type: "5m", coin: "btc", limit: 10 })
// The newest market may still be running, so take the first resolved one
const market = markets.items.find((m) => m.winner !== null)
if (!market) throw new Error("No resolved market on this page")
const page = await api.snapshots(market.market_id, { limit: 5 })
for (const shot of page.items) {
console.log(shot.time, shot.price_up, shot.price_down)
}curl -H "X-API-Key: $POLYTEST_KEY" \
"https://api.polytest.io/api/v1/markets/1496946/snapshots?limit=5"res = requests.get(
f"https://api.polytest.io/api/v1/markets/{market_id}/snapshots",
headers={"X-API-Key": API_KEY},
params={"limit": 5}
)
snapshots = res.json()["snapshots"]
for s in snapshots:
print(s["time"], f"Up: {s['price_up']}", f"Down: {s['price_down']}")const res = await fetch(
`https://api.polytest.io/api/v1/markets/${marketId}/snapshots?limit=5`,
{ headers: { "X-API-Key": API_KEY } }
);
const { snapshots } = await res.json();
snapshots.forEach(s => console.log(s.time, s.price_up));