Polymarket_http.ClientSourceGeneric 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.
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.
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.
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_errorStructured 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
val handle_response :
status_code ->
string ->
(string -> ('a, error) result) ->
('a, error) resultHandle HTTP response status and parse body.
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.