package polymarket
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page
OCaml client library for the Polymarket prediction market API
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.2.0.tar.gz
md5=4eb4c5d2f63ff081c9713d90be5a51b2
sha512=0e3de0c9b40683e09ab8f9f966a44784ef1b9b482c3eefef84104a7e8042c92f1d79893ee9588b24fa3d0decaed7f365509f4d1c23c66ce8328efb64e721f276
doc/polymarket.rate_limiter/Polymarket_rate_limiter/Rate_limiter/index.html
Module Polymarket_rate_limiter.Rate_limiterSource
Route-based rate limiting for HTTP clients.
This library provides GCRA-based rate limiting with route matching, supporting multiple limits per route and configurable delay/error behaviors.
Quick Start
(* Create a shared rate limiter with Polymarket API limits *)
let routes = Polymarket_common.Rate_limit_presets.all ~behavior:Delay in
let rate_limiter =
Rate_limiter.create ~routes ~clock:(Eio.Stdenv.clock env) ()
in
(* Pass to all API clients *)
let gamma = Gamma.create ~sw ~net ~rate_limiter () in
let data = Data.create ~sw ~net ~rate_limiter () inFeatures
- Route matching: Match requests by host, HTTP method, and path prefix
- Multiple limits: Stack burst and sustained limits on the same route
- GCRA algorithm: Fair rate limiting using Generic Cell Rate Algorithm
- Configurable behavior: Delay requests or return errors per route
Core Types
Route matching pattern
Rate limit configuration
Source
type route_config = Types.route_config = {pattern : route_pattern;limits : limit_config list;behavior : behavior;
}Complete route configuration
Rate Limiter
Rate limiter state
Raised by before_request when behavior is Error and limit exceeded
Source
val create :
routes:route_config list ->
clock:_ Eio.Time.clock ->
?max_idle_time:float ->
unit ->
tCreate a rate limiter with custom routes.
Update the rate limit routes at runtime
Check rate limits before making a request.
- For
Delaybehavior: sleeps until the request is allowed - For
Errorbehavior: raisesRate_limit_exceededif limit exceeded
Like before_request but returns a result instead of raising.
State Management
Sub-modules
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page