Polymarket.Data (Polymarket v0.2.0)

Copy Markdown View Source

Read-only wrappers for Polymarket's public Data API.

All endpoints are public GETs against Polymarket.Config.data_api_host/0 (https://data-api.polymarket.com). No authentication is required — the wallet address is passed as a query parameter, so callers can read any address they have, not just their own.

This is the source of truth for fee-inclusive trade costs (/activity) and current holdings including unredeemed winners (/positions). The CLOB fills endpoint reports size * price and excludes taker fees; prefer Data API usdcSize when computing P&L on completed BUY → REDEEM cycles.

Response shape and options

All wrappers delegate to Polymarket.HTTP.get/3. See its @moduledoc for the response contract and the per-call options list (:host, :plug, :timeout, :retry, :max_retries, :headers).

GET requests default to Req's :transient retry policy; pass retry: false to disable.

Summary

Functions

Lists activity (trades + redemptions) for a wallet address.

Lists current positions for a wallet address.

Lists public trade history for a wallet address.

Types

result()

@type result() :: Polymarket.HTTP.result()

Functions

get_activity(address, opts \\ [])

@spec get_activity(
  String.t(),
  keyword()
) :: result()

Lists activity (trades + redemptions) for a wallet address.

Activity events include:

  • TRADE — buys and sells with fee-inclusive usdcSize (the actual wallet debit/credit, including taker fees).
  • REDEEM — payouts on resolved markets.

Records are keyed by transactionHash, not by order hash.

Options

  • :limit — max events to return (default 1000).
  • :offset — pagination offset.
  • Plus any option supported by Polymarket.HTTP.get/3.

get_positions(address, opts \\ [])

@spec get_positions(
  String.t(),
  keyword()
) :: result()

Lists current positions for a wallet address.

Returns positions with camelCase fields as sent by the Data API — including size, avgPrice, currentValue, and redeemable. This wrapper does not normalize keys to snake_case; pipe the result through Polymarket.Activity or your own mapper if you need that.

Options

  • :size_threshold — minimum position size to return (default 0.1). The Data API filters dust positions on the server side.
  • Plus any option supported by Polymarket.HTTP.get/3.

Pagination

This wrapper does not send limit/offset. The Data API defaults to limit=100, so wallets with more than 100 positions are truncated by the server. Paginated fetching is not yet exposed here.

get_trades(address, opts \\ [])

@spec get_trades(
  String.t(),
  keyword()
) :: result()

Lists public trade history for a wallet address.

Options

  • :limit — max trades to return (default 20).
  • :after — sent as-is to the API. Note: the live Data API GET /trades endpoint does not currently document an after filter, so this may be ignored server-side — do not rely on it for time-windowing until verified against the live API.
  • :asset_id — sent as-is. Note: the live GET /trades endpoint does not currently document an asset filter, so this may likewise be ignored server-side.
  • Plus any option supported by Polymarket.HTTP.get/3.