package polymarket
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=4eb4c5d2f63ff081c9713d90be5a51b2
sha512=0e3de0c9b40683e09ab8f9f966a44784ef1b9b482c3eefef84104a7e8042c92f1d79893ee9588b24fa3d0decaed7f365509f4d1c23c66ce8328efb64e721f276
doc/polymarket.http/Polymarket_http/Client/index.html
Module Polymarket_http.ClientSource
Generic HTTP client for Polymarket APIs.
This module provides a reusable HTTP client. Uses cohttp-eio for HTTP requests. Use the Builder module for type-safe request construction.
Client Configuration
The client type holding connection configuration
val create :
base_url:string ->
sw:Eio.Switch.t ->
net:_ Eio.Net.t ->
rate_limiter:Polymarket_rate_limiter.Rate_limiter.t ->
unit ->
tCreate a new client instance.
HTTP Request Functions
Query parameters type
Build a URI from base URL, path, and query parameters
HTTP status code
Perform a GET request and return status code and body.
val do_post :
?headers:(string * string) list ->
t ->
Uri.t ->
body:string ->
status_code * stringPerform a POST request with JSON body and return status code and body.
Perform a DELETE request and return status code and body.
val do_delete_with_body :
?headers:(string * string) list ->
t ->
Uri.t ->
body:string ->
status_code * stringPerform a DELETE request with JSON body and return status code and body.
Error Handling
HTTP error with status code, raw body, and extracted message
Parse error with context and message
Network-level error (connection failed, timeout, etc.)
type error = | Http_error of http_error| Parse_error of parse_error| Network_error of network_error(*Structured error type for all API errors
*)
Pretty printer for errors
Legacy type alias for backwards compatibility
Parse an error response from a JSON body and status code
Response Handling
val handle_response :
status_code ->
string ->
(string -> ('a, error) result) ->
('a, error) resultHandle HTTP response status and parse body.
JSON Field Checking
These functions log warnings when API responses contain fields not defined in our types. Use with @@deriving yojson_fields to generate field lists.
val check_extra_fields :
expected_fields:string list ->
context:string ->
Yojson.Safe.t ->
unitCheck a JSON value for unexpected fields and log warnings.
val parse_with_field_check :
expected_fields:string list ->
context:string ->
string ->
(Yojson.Safe.t -> 'a) ->
('a, error) resultParse JSON with extra field checking for single objects.
val parse_list_with_field_check :
expected_fields:string list ->
context:string ->
string ->
(Yojson.Safe.t -> 'a) ->
('a, error) resultParse JSON with extra field checking for lists of objects.