package polymarket
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=4eb4c5d2f63ff081c9713d90be5a51b2
sha512=0e3de0c9b40683e09ab8f9f966a44784ef1b9b482c3eefef84104a7e8042c92f1d79893ee9588b24fa3d0decaed7f365509f4d1c23c66ce8328efb64e721f276
doc/polymarket.clob/Polymarket_clob/Client/index.html
Module Polymarket_clob.ClientSource
Typestate-authenticated HTTP client for the Polymarket CLOB API.
This module provides compile-time enforcement of authentication requirements for the CLOB API. Three authentication levels are available:
Unauthed: Public endpoints only (order book, pricing, timeseries)L1: L1 wallet authentication (create/derive API keys) + public endpointsL2: L2 API key authentication (orders, trades) + L1 + public endpoints
The typestate pattern ensures that authentication-required endpoints can only be called on clients with the appropriate credentials configured.
Typical Usage
(* Start with an unauthenticated client for public data *)
let client = Unauthed.create ~sw ~net ~rate_limiter () in
let order_book = Unauthed.get_order_book client ~token_id () in
(* Upgrade to L1 for wallet-based operations *)
let l1_client = upgrade_to_l1 client ~private_key in
(* Derive API credentials and upgrade to L2 *)
match L1.derive_api_key l1_client ~nonce:0 with
| Ok (l2_client, _resp) ->
(* Now we can create orders *)
let _ = L2.create_order l2_client ~order ~owner ~order_type () in
()
| Error e -> failwith e.errorRe-exported authentication types from common.
Re-exported cryptographic utilities from common.
Default base URL for the CLOB API: https://clob.polymarket.com
Client Types
These abstract types represent the three authentication levels.
Unauthenticated client for public endpoints only.
L1-authenticated client with private key for wallet operations.
L2-authenticated client with full API access.
State Transitions
Functions to upgrade or downgrade authentication levels.
Upgrade an unauthenticated client to L1 by providing a private key. The address is derived from the private key automatically.
Upgrade an L1 client to L2 by providing API credentials.
Downgrade an L2 client to unauthenticated (for public endpoints only).