package polymarket

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Client.L2Source

L2-Authenticated Client

Provides L2 (API key-based) authentication for order management, trades, and all other authenticated endpoints, plus L1 and public endpoints. L2 authentication uses HMAC-SHA256 signatures with the API credentials.

Sourcetype t = l2

L2-authenticated client with full API access.

Sourceval create : ?base_url:string -> sw:Eio.Switch.t -> net:_ Eio.Net.t -> rate_limiter:Polymarket_rate_limiter.Rate_limiter.t -> private_key:Crypto.private_key -> credentials:Auth.credentials -> unit -> t

Create a new L2-authenticated CLOB client.

  • parameter sw

    The Eio switch for resource management

  • parameter net

    The Eio network interface

  • parameter rate_limiter

    Shared rate limiter for enforcing API limits

  • parameter private_key

    The wallet's private key (for L1 operations)

  • parameter credentials

    The API credentials (api_key, secret, passphrase)

Sourceval address : t -> string

Get the Ethereum address derived from the private key.

Sourceval credentials : t -> Auth.credentials

Get the API credentials.

L1 Authentication Endpoints

Sourceval create_api_key : t -> nonce:int -> (Auth.api_key_response, Polymarket_http.Client.error) result

Create a new API key using L1 wallet authentication.

Sourceval delete_api_key : t -> (unit, Polymarket_http.Client.error) result

Delete the current API key.

Sourceval get_api_keys : t -> (string list, Polymarket_http.Client.error) result

Get all API keys for this address.

Orders

Sourceval create_order : t -> order:Types.signed_order -> owner:string -> order_type:Types.Order_type.t -> unit -> (Types.create_order_response, Polymarket_http.Client.error) result

Create a new order on the CLOB.

Sourceval create_orders : t -> orders:(Types.signed_order * string * Types.Order_type.t) list -> unit -> (Types.create_order_response list, Polymarket_http.Client.error) result

Create multiple orders on the CLOB.

Sourceval get_order : t -> order_id:string -> unit -> (Types.open_order, Polymarket_http.Client.error) result

Get details of a specific order.

Sourceval get_orders : t -> ?market:string -> ?asset_id:string -> unit -> (Types.open_order list, Polymarket_http.Client.error) result

Get all open orders, optionally filtered by market or asset.

Cancel Orders

Sourceval cancel_order : t -> order_id:string -> unit -> (Types.cancel_response, Polymarket_http.Client.error) result

Cancel a specific order.

Sourceval cancel_orders : t -> order_ids:string list -> unit -> (Types.cancel_response, Polymarket_http.Client.error) result

Cancel multiple orders.

Cancel all open orders.

Sourceval cancel_market_orders : t -> ?market:string -> ?asset_id:string -> unit -> (Types.cancel_response, Polymarket_http.Client.error) result

Cancel all orders for a market or asset.

Trades

Sourceval get_trades : t -> ?id:string -> ?taker:string -> ?maker:string -> ?market:string -> ?before:string -> ?after:string -> unit -> (Types.clob_trade list, Polymarket_http.Client.error) result

Get trade history.

Order Book

Sourceval get_order_book : t -> token_id:string -> unit -> (Types.order_book_summary, Polymarket_http.Client.error) result
Sourceval get_order_books : t -> token_ids:string list -> unit -> (Types.order_book_summary list, Polymarket_http.Client.error) result

Pricing

Sourceval get_price : t -> token_id:string -> side:Polymarket_clob.Types.Side.t -> unit -> (Types.price_response, Polymarket_http.Client.error) result
Sourceval get_midpoint : t -> token_id:string -> unit -> (Types.midpoint_response, Polymarket_http.Client.error) result
Sourceval get_prices : t -> requests:(string * Polymarket_clob.Types.Side.t) list -> unit -> (Types.prices_response, Polymarket_http.Client.error) result
Sourceval get_spreads : t -> token_ids:string list -> unit -> (Types.spreads_response, Polymarket_http.Client.error) result

Timeseries

Sourceval get_price_history : t -> market:string -> ?start_ts:int -> ?end_ts:int -> ?interval:Types.Interval.t -> ?fidelity:int -> unit -> (Types.price_history, Polymarket_http.Client.error) result