Skip to main content

Quickstart

Get up and running with the Context SDK. This guide covers reading market data — no wallet required.

Prerequisites

  • Node.js 18+ or Bun

Setup

mkdir context-quickstart && cd context-quickstart
npm init -y
npm install @contextwtf/sdk
Create a script file:
// index.ts
import { ContextClient } from "@contextwtf/sdk"

const ctx = new ContextClient()

1. List markets

const { markets } = await ctx.markets.list({ sortBy: "trending", limit: 5 })

for (const m of markets) {
  console.log(`${m.question} (${m.id.slice(0, 10)}...)`)
}

2. Get quotes

const marketId = markets[0].id

const quotes = await ctx.markets.quotes(marketId)

if (quotes.yes.bid && quotes.yes.ask) {
  console.log(`Yes: ${quotes.yes.bid}¢ bid / ${quotes.yes.ask}¢ ask`)
  console.log(`Spread: ${quotes.spread}¢`)
}

3. Get the orderbook

const book = await ctx.markets.orderbook(marketId, { depth: 5 })

console.log("Bids:")
for (const bid of book.bids) {
  console.log(`  ${bid.price}¢ — ${bid.size} contracts`)
}

console.log("Asks:")
for (const ask of book.asks) {
  console.log(`  ${ask.price}¢ — ${ask.size} contracts`)
}

Run it

npx tsx index.ts

Next steps