TypeScript SDK
Installation
Copy
Ask AI
npm install @gimme-fast/sdk
The package will be published to npm soon. For now, install from the GitHub repository.
Quick Start
Copy
Ask AI
import { GimmeClient } from "@gimme-fast/sdk";
const client = new GimmeClient({ apiKey: "gf_your_key_here" });
// List active markets
const markets = await client.markets.list({ active: true, limit: 10 });
console.log(markets);
// Get a specific market
const market = await client.markets.get("market-uuid");
// Get current price
const price = await client.pricing.getPrice("token-id");
console.log(`Price: $${price.price}, 24h volume: $${price.volume_24h}`);
REST Client
Markets
Copy
Ask AI
// List markets with filters
const markets = await client.markets.list({
active: true,
search: "bitcoin",
limit: 20,
offset: 0,
});
// Get single market
const market = await client.markets.get("market-uuid");
Trades
Copy
Ask AI
// Recent trades
const trades = await client.trades.list({ limit: 50 });
// Trades for a specific token
const tokenTrades = await client.trades.byToken("token-id", { limit: 100 });
Pricing
Copy
Ask AI
// Current price + 24h stats
const price = await client.pricing.getPrice("token-id");
// OHLCV candles
const candles = await client.pricing.getCandles("token-id", {
resolution: "1h",
limit: 24,
});
Orderbook
Copy
Ask AI
const book = await client.orderbook.get("token-id");
console.log(`Best bid: ${book.bids[0]?.price}, Best ask: ${book.asks[0]?.price}`);
WebSocket Client
Copy
Ask AI
import { GimmeWebSocket } from "@gimme-fast/sdk";
const ws = new GimmeWebSocket({
apiKey: "gf_your_key_here",
compress: true, // Enable zlib compression
});
// Event handlers
ws.on("trade", (trade) => {
console.log(`${trade.side} ${trade.size} @ ${trade.price}`);
});
ws.on("resolution", (resolution) => {
console.log(`Market resolved: ${resolution.condition_id}`);
});
ws.on("connected", () => {
console.log("Connected to WebSocket");
// Subscribe to all trades
ws.subscribe({ type: "trades" });
// Or subscribe to a specific token
ws.subscribe({ type: "tokentrades", token_id: "21742633..." });
// Or market resolutions
ws.subscribe({ type: "resolutions" });
});
ws.on("error", (error) => {
console.error("WebSocket error:", error);
});
// Connect
ws.connect();
// Later: unsubscribe
ws.unsubscribe({ type: "trades" });
// Disconnect
ws.close();
Auto-Reconnection
The WebSocket client automatically reconnects with exponential backoff if the connection drops. You don’t need to handle reconnection logic — just set up your event handlers and subscriptions.Copy
Ask AI
ws.on("reconnected", () => {
console.log("Reconnected — re-subscribing...");
ws.subscribe({ type: "trades" });
});
Configuration
Copy
Ask AI
const client = new GimmeClient({
apiKey: "gf_your_key",
baseUrl: "https://api.gimme.fast", // Custom base URL (optional)
});
const ws = new GimmeWebSocket({
apiKey: "gf_your_key",
url: "wss://ws.gimme.fast/ws", // Custom WebSocket URL (optional)
compress: true, // Enable zlib compression
});
Error Handling
Copy
Ask AI
import { GimmeError } from "@gimme-fast/sdk";
try {
const market = await client.markets.get("nonexistent");
} catch (error) {
if (error instanceof GimmeError) {
console.log(error.status); // 404
console.log(error.code); // "NOT_FOUND"
console.log(error.message); // "Market not found"
}
}