package polymarket

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

Module Polymarket_common.AuthSource

Authentication types and header builders for Polymarket APIs.

This module provides credentials types and functions for building authentication headers for L1 (wallet-based) and L2 (API key-based) authentication.

Types

Sourcetype credentials = {
  1. api_key : string;
  2. secret : string;
    (*

    Base64-encoded secret

    *)
  3. passphrase : string;
}

API credentials for L2 authentication.

Sourceval pp_credentials : Format.formatter -> credentials -> unit
Sourceval show_credentials : credentials -> string
Sourceval equal_credentials : credentials -> credentials -> bool
Sourcetype api_key_response = {
  1. api_key : string;
  2. secret : string;
  3. passphrase : string;
}

Response from API key endpoints (create or derive).

Sourceval api_key_response_of_yojson : Yojson.Safe.t -> api_key_response
Sourceval yojson_of_api_key_response : api_key_response -> Yojson.Safe.t
Sourceval pp_api_key_response : Format.formatter -> api_key_response -> unit
Sourceval show_api_key_response : api_key_response -> string
Sourceval equal_api_key_response : api_key_response -> api_key_response -> bool

Conversion

Sourceval credentials_of_api_key_response : api_key_response -> credentials

Convert API key response to credentials.

L1 Authentication

L1 authentication uses EIP-712 signed messages to prove wallet ownership. It's used for creating and deriving API credentials.

Sourceval build_l1_headers : private_key:Crypto.private_key -> address:string -> nonce:int -> (string * string) list

Build L1 authentication headers for wallet-based endpoints.

  • parameter private_key

    The Ethereum private key (hex, without 0x prefix)

  • parameter address

    The Ethereum address (hex, with 0x prefix)

  • parameter nonce

    A unique nonce for this request

L2 Authentication

L2 authentication uses HMAC-SHA256 to sign requests using API credentials. It's used for authenticated trading and account management endpoints.

Sourceval build_l2_headers : credentials:credentials -> address:string -> method_:string -> path:string -> body:string -> (string * string) list

Build L2 authentication headers for API key-authenticated endpoints.

  • parameter credentials

    The API credentials (api_key, secret, passphrase)

  • parameter address

    The Ethereum address (hex, with 0x prefix)

  • parameter method_

    The HTTP method (GET, POST, DELETE)

  • parameter path

    The request path (e.g., "/orders")

  • parameter body

    The request body (empty string for GET/DELETE)