PolymarketClob (PolymarketClob v0.2.0)

Copy Markdown View Source

Standalone Elixir client for the Polymarket CLOB API.

This package owns the low-level CLOB surface only — auth, EIP-712 order signing, order placement, balances, order books, prices, and per-market metadata. Higher-level Polymarket features (Gamma market discovery, Data API normalization, RTDS, CTF, pUSD) are intentionally out of scope and live in separate packages.

Layered API

The recommended usage pattern is to call the API submodules directly. This module exposes only a small client-construction shorthand and a version helper; it intentionally does not shadow the layered API.

See ENDPOINT_COVERAGE.md for the full HTTP endpoint mapping against the audited Polymarket/py-clob-client-v2 commit.

Quick start

client =
  PolymarketClob.client(
    private_key: System.fetch_env!("POLY_PRIVATE_KEY"),
    api_key: System.get_env("POLY_API_KEY"),
    api_secret: System.get_env("POLY_API_SECRET"),
    api_passphrase: System.get_env("POLY_API_PASSPHRASE")
  )

{:ok, book} = PolymarketClob.API.MarketData.get_order_book("123456")
{:ok, balance} = PolymarketClob.API.Account.get_balance_allowance(client)

See PolymarketClob.Client.new/1 for the full option list and signature-type auto-detection rules. With API credentials present, the client defaults to signature type 2 (Polymarket Gnosis Safe). Without them, it defaults to 0 (EOA).

Parity with py-clob-client-v2

Order amount calculation, EIP-712 signing, ClobAuth-with-nonce, and HMAC L2 request signing are validated against deterministic fixtures generated from the official Python client. See test/fixtures/parity/ and scripts/generate_parity_fixtures.py.

Summary

Functions

Returns the package version.

Functions

client(opts)

@spec client(keyword()) :: PolymarketClob.Client.t()

Builds a PolymarketClob.Client.

Convenience shorthand for PolymarketClob.Client.new/1. See that function for the full option list, address derivation, and signature-type defaults.

version()

@spec version() :: String.t()

Returns the package version.

Derived from the loaded application spec so it always tracks mix.exs.