PolymarketClob

Standalone Elixir client for the Polymarket CLOB API.

This package is being built as the first publishable version of polymarket_clob. It targets Polymarket's current exchange model and starts from fixture-proven auth and order-signing primitives before adding higher-level HTTP, order construction, and WebSocket APIs.

Current Status

Implemented:

Not implemented yet:

Examples

Client

client =
PolymarketClob.Client.new(
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")
)

If API credentials are omitted, the client defaults to EOA signature type 0. If all API credential fields are present, it defaults to Polymarket Gnosis Safe signature type 2. Partial API credentials raise.

Public Market Data Reads

{:ok, book} =
PolymarketClob.API.MarketData.get_order_book("1234567890")
{:ok, price} =
PolymarketClob.API.MarketData.get_price("1234567890", :buy)
{:ok, market_info} =
PolymarketClob.API.MarketData.get_clob_market_info("0xconditionid")

Private Account Reads

{:ok, balance} =
PolymarketClob.API.Account.get_balance_allowance(client,
asset_type: "CONDITIONAL",
token_id: "1234567890"
)
{:ok, open_orders_page} =
PolymarketClob.API.Account.get_open_orders(client,
market: "0xconditionid",
next_cursor: "MA=="
)
{:ok, trades_page} =
PolymarketClob.API.Account.get_trades(client,
market: "0xconditionid",
next_cursor: "MA=="
)

Private GET requests sign the base endpoint path, matching the official Python client, while query params are still appended to the URL sent to the CLOB.

Local Signed Limit Order

signed_order =
PolymarketClob.Order.Builder.build_limit_order(
client,
"1234567890",
10.0,
0.55,
:buy,
tick_size: "0.01",
neg_risk: false
)

This only builds and signs the order locally. To post an already-built signed order:

{:ok, response} =
PolymarketClob.API.Orders.post_order(client, signed_order)

Endpoint Coverage

Audited against Polymarket/py-clob-client-v2 commit a2ec069fb66096e2b80ff0b7fdf628fc41d6352c.

Coverage as of the audited commit: 44 of 50 candidate endpoints implemented (rewards, RFQ, and builder surface are intentionally skipped — see ENDPOINT_COVERAGE.md).

Implemented public read-only endpoints:

Implemented private read-only endpoints:

Implemented private write endpoints:

Not implemented yet:

Intentional differences from the Python client:

Installation

After publication, add polymarket_clob to your dependencies:

def deps do
[
{:polymarket_clob, "~> 0.1.0"}
]
end

Fixture Generation

The checked-in fixtures under test/fixtures/parity were generated from the official Python v2 client at commit a2ec069fb66096e2b80ff0b7fdf628fc41d6352c:

PY_CLOB_CLIENT_V2_PATH=/path/to/py-clob-client-v2 \
python3 scripts/generate_parity_fixtures.py

The script defaults to /tmp/py-clob-client-v2, which is useful for local scratch checkouts during development.