### Example Usage Source: https://docs.polynode.dev/quickstart This snippet demonstrates how to use the Polynode API to get a response. ```javascript import { Polynode } from "@polynode/polynode"; const polynode = new Polynode(); async function main() { const resp = await polynode.json(); console.log(resp); } main(); ``` -------------------------------- ### Python Example Source: https://docs.polynode.dev/quickstart Example of how to create a bot using Python. ```python import requests resp = requests.post("https://api.polynode.dev/v1/keys", json={"name": "my-bot"}) key = resp.json()["api_key"] print(key) # pn_live_a1b2c3d4e5f6... ``` -------------------------------- ### Node.js Example Source: https://docs.polynode.dev/quickstart Example of how to create a bot using Node.js. ```javascript import { Polynode } from "@polynode/polynode"; const pn = new Polynode(); pn.createBot({ name: "my-bot" }); ``` -------------------------------- ### TypeScript Quickstart Source: https://docs.polynode.dev/quickstart Example of how to generate an API key using TypeScript. ```typescript import { PolynodeClient } from "@polynode/client"; const client = new PolynodeClient("YOUR_API_KEY"); async function main() { const key = await client.keys.create("my-bot"); console.log(key.apiKey); } main(); ``` -------------------------------- ### Python Example for Polynode Trader Setup Source: https://docs.polynode.dev/guides/polyusd A Python code snippet demonstrating how to initialize the Polynode Trader with necessary configurations, including API keys and exchange versions. ```python # polynode >= 0.9.1 from polynode.trading import PolyNodeTrader, TraderConfig, ExchangeVersion, BuilderCredentials trader = PolyNodeTrader(TraderConfig( "pn_live_...", exchange_version=ExchangeVersion.V1 )) ``` -------------------------------- ### Response Example Source: https://docs.polynode.dev/quickstart This snippet shows an example of a JSON response from the Polynode API. ```json { "count": 5, "total": 69482, "markets": [ { "token_id": "247024838963513327646981976118812247380", "question": "Will Bitcoin reach $100k?", "last_price": ``` -------------------------------- ### Example Data Structure Source: https://docs.polynode.dev/quickstart This snippet shows an example of the data structure for a market. ```javascript { title: \ ``` ```javascript volume_24h: 48293.50, trade_count_24h: 677, last_trade_at: 1772512467000, slug: \ ``` ```javascript outcomes: [\ ``` ```javascript } ] } ``` -------------------------------- ### Quick Start: Get Most Recent 100 Trades Source: https://docs.polynode.dev/api-reference/onchain/wallet-trades A quick start example to retrieve the most recent 100 trades for a wallet using cURL. ```shell curl "https://api.polynode.dev/v2/onchain/wallets/{address}/trades?limit=100" \ -H "x-api-key: YOUR_KEY" ``` -------------------------------- ### Example Usage Source: https://docs.polynode.dev/quickstart This example demonstrates how to subscribe to real-time trade data for a specific market. ```javascript import { Polynode } from "@polynode/polynode-js"; const client = new Polynode("YOUR_API_KEY"); async function main() { const stream = await client.stream.trades({ market: "BTC-PERPETUAL", }); stream.on("data", (data) => { console.log(`Received trade: ${data.taker_side} ${data.taker_price} @ ${data.taker_size}`); }); } main(); ``` -------------------------------- ### Quick start — get the most recent 100 trades Source: https://docs.polynode.dev/api-reference/onchain/wallet-trades This example shows how to retrieve the most recent 100 trades for a given wallet address. ```bash curl -X GET \"https://api.polynode.dev/v2/onchain/wallets/0x1234567890abcdef1234567890abcdef12345678\/trades?limit=100\" \ -H \"accept: application/json\" ``` -------------------------------- ### Quick start — get the most recent 100 trades Source: https://docs.polynode.dev/api-reference/onchain/market-trades This example demonstrates how to retrieve the most recent 100 trades for a given market token. ```bash curl -X GET \"https://api.polynode.dev/v2/onchain/markets/0x1234567890abcdef1234567890abcdef12345678/trades?limit=100\" \ -H \"accept: application/json\" ``` -------------------------------- ### Make Your First Request Source: https://docs.polynode.dev/quickstart Example of fetching the top 5 markets by 24h volume using cURL. ```bash curl -s "https://api.polynode.dev/v1/markets?count=5" \ -H "x-api-key: pn_live_YOUR_KEY" | jq ``` -------------------------------- ### Quick start — get the most recent 100 trades Source: https://docs.polynode.dev/api-reference/onchain/market-trades Example cURL command to fetch the most recent 100 trades for a market token. ```shell curl "https://api.polynode.dev/v2/onchain/markets/{token_id}/trades?limit=100" \ -H "x-api-key: YOUR_KEY" ``` -------------------------------- ### Fetch Markets Example Source: https://docs.polynode.dev/quickstart An example demonstrating how to fetch market data from the Polynode API using JavaScript. ```javascript const resp = await fetch("https://api.polynode.dev/v1/markets?count=5", { headers: { "x-api-key": "pn_live_YOUR_KEY" } }); const data = await resp.json(); print(resp.json()); ``` -------------------------------- ### Full Lifecycle Tracking Source: https://docs.polynode.dev/guides/trade-tracking This example demonstrates how to track both pending and confirmed trades by matching the 'maker' field to get the complete picture of a trade's lifecycle. ```javascript const pending = new Map(); ws.onmessage = (event) => { const msg = JSON.parse(event.data); if (msg.type === "settlement" && msg.data.status === "pending") { // Find the wallet's actual leg in the pending trades array const myLeg = msg.data.trades.find( t => t.maker.toLowerCase() === WALLET_IM_TRACKING.toLowerCase() ); if (myLeg) { pending.set(msg.data.tx_hash, { detected_at: Date.now(), pending_price: myLeg.price, pending_side: myLeg.side, }); } } if (msg.type === "status_update" && msg.data.confirmed_fills) { const original = pending.get(msg.data.tx_hash); const lead_time = original ? msg.data.confirmed_at - original.detected_at : null; // Match by maker in confirmed_fills too — same rule for (const fill of msg.data.confirmed_fills) { if (fill.maker.toLowerCase() === WALLET_IM_TRACKING.toLowerCase()) { console.log({ market: msg.data.market_title, side: fill.side, pending_price: original?.pending_price, confirmed_price: fill.price, lead_time_ms: lead_time, block: msg.data.block_number, }); } } pending.delete(msg.data.tx_hash); } }; ``` -------------------------------- ### Fetch Top Markets Source: https://docs.polynode.dev/quickstart Example cURL command to fetch the top 5 markets by 24h volume. ```bash curl -X GET "https://api.polynode.dev/v1/markets?limit=5&order_by=volume_24h" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Example Usage Source: https://docs.polynode.dev/webhooks/management/get Example of how to get webhook configuration using curl. ```shellscript curl "https://api.polynode.dev/v3/webhooks/wh_451e06ca0534" \ -H "x-api-key: pn_live_..." ``` -------------------------------- ### Generate an API Key Source: https://docs.polynode.dev/quickstart Example of how to generate an API key using cURL. ```bash curl -s -X POST https://api.polynode.dev/v1/keys \ -H "Content-Type: application/json" \ -d '{"name": "my-bot"}' ``` -------------------------------- ### Example Response Source: https://docs.polynode.dev/api-reference/polymarket-profiles/get-profile Example JSON response for the GET /v3/polymarket/profiles/{address} endpoint. ```json { "address": "0xc3579b0c908f43d50c63951a30c6f72fcea4f6a0", "proxy_wallet": "0xf6d30d58add6c6814d1b086ec543a16ab6cc9a31" } ``` -------------------------------- ### Example of retrieving and processing trade data Source: https://docs.polynode.dev/guides/trade-tracking This snippet demonstrates how to get the current time, iterate through pending transactions, and log details for transactions detected within the last 15 seconds. ```javascript const now = Date.now(); for (const [txHash, data] of pending) { if (now - data.detected_at > 15000) { console.log("\"Transaction detected more than 15 seconds ago: \"", txHash); } } ``` -------------------------------- ### Example Usage Source: https://docs.polynode.dev/quickstart This snippet demonstrates how to use the Polynode API to subscribe to settlement events. ```javascript import { Polynode } from "@polynode/polynode-sdk"; const client = new Polynode({ apiKey: "YOUR_API_KEY", }); client.on("settlement", (msg) => { console.log(`Settlement: ${JSON.stringify(msg, null, 2)} `); }); client.on("error", (err) => { console.error(err); }); client.subscribe({ channel: "settlement", // You can filter by taker_side, taker_side, taker_price // Example: taker_side: "taker", taker_side: "maker", taker_price: "@" }); // You will receive a snapshot of recent events, then live updates as new settlements are detected. ``` -------------------------------- ### Fetch Markets Example (TypeScript) Source: https://docs.polynode.dev/quickstart A TypeScript version of the fetch markets example. ```typescript const resp = await fetch("https://api.polynode.dev/v1/markets?count=5", { headers: { "x-api-key": "pn_live_YOUR_KEY" } }); const data = await resp.json(); ``` -------------------------------- ### Example Request Source: https://docs.polynode.dev/api-reference/polymarket-profiles/get-profile Example of how to call the Get Profile API endpoint using curl. ```shellscript curl \ "https://api.polymarket.link/v3/polymarket/profiles/0x1234567890abcdef1234567890abcdef12345678" ``` -------------------------------- ### Get Webhook Example Source: https://docs.polynode.dev/webhooks/management/get This example demonstrates how to retrieve a webhook by its ID using the Polynode Management API. ```bash curl -X GET \"https://api.polynode.dev/v1/webhooks/YOUR_WEBHOOK_ID\" \"-H \"Authorization: Bearer YOUR_API_KEY\" ``` -------------------------------- ### GET /v3/resolutions Request Example Source: https://docs.polynode.dev/llms-full.txt Example of how to make a GET request to the /v3/resolutions endpoint. ```bash curl https://api.polynode.dev/v3/resolutions?limit=1 ``` -------------------------------- ### API Key Generation Source: https://docs.polynode.dev/quickstart Example of generating an API key using the Polynode SDK. ```javascript import { Polynode } from "@polynode/polynode"; const polynode = new Polynode("YOUR_API_KEY"); async function createBot() { const resp = await polynode.bots.create({ name: "my-bot", rate_limit_per_minute: 120, message: "Store this key securely — it cannot be retrieved again." }); console.log(resp.json()); } createBot(); ``` -------------------------------- ### Zero-Config Quickstart with PolyNodeCache Source: https://docs.polynode.dev/llms-full.txt A TypeScript example showing how to initialize PolyNode, PolyNodeCache, add wallets to the watchlist, and query cached trade data. ```typescript import { PolyNode, PolyNodeCache, getActiveTestWallet } from 'polynode-sdk'; const pn = new PolyNode({ apiKey: 'pn_live_...' }); const wallet = await getActiveTestWallet(); const cache = new PolyNodeCache(pn, { dbPath: './cache.db', watchlistPath: './polynode.watch.json', }); await cache.start(); cache.addToWatchlist([{ type: 'wallet', id: wallet, label: 'test-trader' }]); // Wait for backfill, then query setTimeout(() => { const trades = cache.walletTrades(wallet, { limit: 10 }); console.log(`${trades.length} trades for ${wallet}`); }, 3000); ```