> ## Documentation Index
> Fetch the complete documentation index at: https://polymarket-data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Install polymarket-data, configure the client, and ship your first integration.

Get up and running with **polymarket-data** in minutes. This guide walks through installation,
configuration, and your first live requests.

<Steps>
  <Step title="Install">
    ```bash theme={null}
    npm install polymarket-data
    # or
    pnpm add polymarket-data
    yarn add polymarket-data
    ```

    The package ships as ESM with bundled TypeScript declarations.
  </Step>

  <Step title="Create a client">
    ```ts theme={null}
    import { Polymarket } from "polymarket-data";

    const client = new Polymarket();
    ```

    ### Optional configuration

    | Option          | Description                                  | Default                            |
    | --------------- | -------------------------------------------- | ---------------------------------- |
    | `dataEndpoint`  | Base URL for the classic data API.           | `https://data-api.polymarket.com`  |
    | `gammaEndpoint` | Base URL for the gamma API.                  | `https://gamma-api.polymarket.com` |
    | `fetch`         | Custom Fetch implementation (for SSR/tests). | `globalThis.fetch`                 |

    ```ts theme={null}
    const client = new Polymarket({
      dataEndpoint: "https://custom-data.polymarket.com",
      gammaEndpoint: "https://custom-gamma.polymarket.com",
      fetch: myCustomFetch,
    });
    ```

    > **Mocking in tests** — pass a stubbed `fetch` that returns predefined payloads. All methods
    > pipe through the injected fetch before validation.
  </Step>

  <Step title="Verify connectivity">
    ```ts theme={null}
    const status = await client.health();
    console.log(status); // { data: "OK" }
    ```

    If this call fails, verify network access and endpoint URLs. The SDK throws `HttpError` for API
    failures and `Error("Network error: …")` for connectivity issues.
  </Step>

  <Step title="Make your first requests">
    ```ts theme={null}
    // Portfolio analytics
    const positions = await client.data.core.getPositions({
      user: "0x56687bf447db6ffa42ffe2204a05edaa20f55839",
      limit: 10,
    });

    // Market discovery
    const markets = await client.gamma.markets.listMarkets({
      closed: false,
      liquidity_num_min: 1000,
      limit: 5,
    });
    ```

    Use named imports for types:

    ```ts theme={null}
    import type { Position, Market } from "polymarket-data";
    ```
  </Step>

  <Step title="Next steps">
    <Columns cols={2}>
      <Card title="Data API" icon="database" href="/data/index">
        Explore positions, trades, activity, holders, and value endpoints.
      </Card>

      <Card title="Gamma API" icon="radar" href="/gamma/index">
        Discover search, comments, series, markets, and events modules.
      </Card>
    </Columns>
  </Step>
</Steps>
