> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polynode.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API

> Typed methods for all 25 REST endpoints

Every REST endpoint has a typed method with full request/response types.

## Markets

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const markets = await pn.markets({ count: 10 });
    const detail = await pn.market(tokenId);
    const bySlug = await pn.marketBySlug('bitcoin-100k');
    const byCondition = await pn.marketByCondition(conditionId);
    const list = await pn.marketsList({ count: 20, sort: 'volume' });
    const results = await pn.search('ethereum', { limit: 5 });
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    let markets = client.markets(Some(10)).await?;
    let detail = client.market("token_id").await?;
    let by_slug = client.market_by_slug("bitcoin-100k").await?;
    let by_cond = client.market_by_condition("0xabc...").await?;
    let list = client.list_markets(&ListMarketsParams {
        count: Some(20), sort: Some("volume".into()), ..Default::default()
    }).await?;
    let results = client.search("ethereum", Some(5), None).await?;
    ```
  </Tab>
</Tabs>

## Pricing

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const candles = await pn.candles(tokenId, { resolution: '1h', limit: 100 });
    const stats = await pn.stats(tokenId);
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    let candles = client.candles("token_id", Some(CandleResolution::OneHour), Some(100)).await?;
    let stats = client.stats("token_id").await?;
    ```
  </Tab>
</Tabs>

## Settlements

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const recent = await pn.recentSettlements({ count: 20 });
    const token = await pn.tokenSettlements(tokenId, { count: 10 });
    const wallet = await pn.walletSettlements(address, { count: 10 });
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    let recent = client.recent_settlements(Some(20)).await?;
    let token = client.token_settlements("token_id", Some(10)).await?;
    let wallet = client.wallet_settlements("0xabc...", Some(10)).await?;
    ```
  </Tab>
</Tabs>

## Wallets & System

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const wallet = await pn.wallet(address);
    const status = await pn.status();
    const key = await pn.createKey('my-bot');
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    let wallet = client.wallet("0xabc...").await?;
    let status = client.status().await?;
    let key = client.create_key(Some("my-bot")).await?;
    ```
  </Tab>
</Tabs>

## Enriched Data

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    // Leaderboard — top 20 traders by profit or volume
    const lb = await pn.leaderboard({ period: 'monthly', sort: 'profit' });

    // Trending — carousel, breaking, hot topics, movers
    const trending = await pn.trending();

    // Activity feed — 50 most recent trades platform-wide
    const feed = await pn.activity();

    // Biggest movers — largest 24h price changes
    const movers = await pn.movers();

    // Trader profile — full stats for any wallet
    const profile = await pn.traderProfile('0xc2e7...');

    // Trader PnL series — cumulative PnL over time
    const pnl = await pn.traderPnl('0xc2e7...', { period: '1W' });

    // Event detail — all sub-markets for an event
    const event = await pn.event('fed-decision-in-april');

    // Markets by category
    const crypto = await pn.marketsByCategory('crypto');
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    let lb = client.leaderboard(Some("monthly"), Some("profit")).await?;
    let trending = client.trending().await?;
    let feed = client.activity().await?;
    let movers = client.movers().await?;
    let profile = client.trader_profile("0xc2e7...").await?;
    let pnl = client.trader_pnl("0xc2e7...", Some("1W")).await?;
    let event = client.event("fed-decision-in-april").await?;
    let crypto = client.markets_by_category("crypto").await?;
    ```
  </Tab>
</Tabs>

<Note>
  Enriched endpoints are rate limited to 1 request per second per API key with 1-3 minute caching.
</Note>

## Error Handling

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import { ApiError } from 'polynode-sdk';

    try {
      await pn.market('invalid-id');
    } catch (err) {
      if (err instanceof ApiError) {
        console.log(err.status, err.message);  // 404, "Market not found"
      }
    }
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    match client.market("invalid-id").await {
        Err(Error::NotFound(msg)) => println!("Not found: {}", msg),
        Err(Error::Auth(msg)) => println!("Auth failed: {}", msg),
        Err(Error::RateLimited(msg)) => println!("Rate limited: {}", msg),
        Err(e) => println!("Other: {}", e),
        Ok(detail) => println!("{:?}", detail),
    }
    ```
  </Tab>
</Tabs>
