Skip to main content
The PMXT SDKs share one configuration surface across hosted and self-hosted modes. The same ExchangeOptions object selects mode, supplies credentials, and overrides defaults. Hosted is the default; self-hosted is the explicit fallback when no pmxt_api_key is present.

ExchangeOptions

Constructor arguments, Python kwargs alongside TypeScript option keys.

Hosted (the default)

Python kwargTypeScript keyTypeRequired?Description
pmxt_api_keypmxtApiKeystrRequired for hostedPMXT API key from pmxt.dev/dashboard. Triggers hosted mode.
wallet_addresswalletAddressstrRequired for hosted writes + escrowAddress that owns the escrow balance and signs orders.
private_keyprivateKeystrRequired for hosted writesEVM private key used to sign EIP-712 typed-data locally. Auto-wrapped into a signer.
signersignerSignerOptional (alt to private_key)Custom signer implementing sign_typed_data / signTypedData. For hardware wallets, MPC, remote signing.
base_urlbaseUrlstrOptionalOverride the default https://api.pmxt.dev. Rarely needed.
trade_base_urltradeBaseUrlstrOptionalOverride the default https://trade.pmxt.dev. Rarely needed.
timeouttimeoutfloat (s)OptionalPer-request timeout in seconds. Default 30.
import pmxt

# Read-only: no private_key
read_only = pmxt.Polymarket(
    pmxt_api_key="pmxt_live_...",
    wallet_address="0xYourWallet...",
)

# Trading-capable: private_key auto-wraps into EthAccountSigner
trader = pmxt.Polymarket(
    pmxt_api_key="pmxt_live_...",
    wallet_address="0xYourWallet...",
    private_key="0xYourPrivateKey...",
)

# Custom signer (hardware wallet, MPC, etc.)
trader = pmxt.Polymarket(
    pmxt_api_key="pmxt_live_...",
    wallet_address="0xYourWallet...",
    signer=my_ledger_signer,
)

Self-hosted (fallback)

When pmxt_api_key is absent, the SDK enters self-hosted mode and routes through the local pmxt-core server. Venue-native credentials apply here.
Python kwargTypeScript keyTypeDescription
private_keyprivateKeystrEVM private key, for Polymarket / Limitless / Probable / Opinion / etc.
api_key_id, private_key_pemapiKeyId, privateKeyPemstrKalshi RSA credentials.
email, passwordemail, passwordstrSmarkets session credentials.
local_portlocalPortintOverride the default pmxt-core port (3847).
See Self-hosted for per-venue credential examples.

Environment variables

VariableEffect
PMXT_API_KEYDefault pmxt_api_key for all SDK clients. Explicit constructor arg wins.
PMXT_BASE_URLOverride api.pmxt.dev. Useful for staging environments.
PMXT_TRADE_BASE_URLOverride trade.pmxt.dev. Useful for staging hosted-trading environments.
PMXT_LOCAL_PORTOverride the local pmxt-core port (default 3847). Self-hosted only.
PMXT_ALWAYS_RESTART=1Force-restart the local pmxt-core on every ensure_server_running call. Useful during local SDK development.
PMXT_TIMEOUTDefault per-request timeout in seconds.
PMXT_LOG_LEVELLog verbosity for SDK + local server: debug, info, warn, error.
Constructor arguments always take precedence over environment variables. The env-var path is for ergonomics in deploy environments where you set PMXT_API_KEY once.

Base URL resolution

When the SDK makes a request, it picks one of three base URLs based on the operation and configuration:
  1. trade.pmxt.dev (hosted trading) — used for /v0/trade/*, /v0/user/*, and /v0/escrow/* whenever pmxt_api_key is set. Override with trade_base_url or PMXT_TRADE_BASE_URL.
  2. api.pmxt.dev (hosted catalog + reads) — used for /v0/markets, /v0/events, /api/{venue}/* whenever pmxt_api_key is set and the operation is not a hosted-trading write. Override with base_url or PMXT_BASE_URL.
  3. http://localhost:3847 (self-hosted) — used for every operation when pmxt_api_key is absent. Override port with local_port or PMXT_LOCAL_PORT.

Precedence (highest to lowest)

  1. Explicit constructor base_url / trade_base_url.
  2. PMXT_BASE_URL / PMXT_TRADE_BASE_URL env var.
  3. Default (https://api.pmxt.dev / https://trade.pmxt.dev / http://localhost:3847).

Worked example

import os
os.environ["PMXT_BASE_URL"] = "https://api-staging.pmxt.dev"

# Hosted mode (because pmxt_api_key is set); base_url comes from env
client = pmxt.Polymarket(pmxt_api_key="pmxt_test_...")
# → reads go to https://api-staging.pmxt.dev
# → trade writes still go to https://trade.pmxt.dev (PMXT_TRADE_BASE_URL not set)

# Self-hosted mode (no pmxt_api_key); env var ignored
local = pmxt.Polymarket(private_key="0x...")
# → reads + writes go to http://localhost:3847

Hosted as default

The configuration philosophy:
  • Setting pmxt_api_key (or PMXT_API_KEY) is the single switch that opts in to hosted mode. No other flag is required.
  • All hosted-specific URLs default to PMXT’s production endpoints — no setup beyond the API key.
  • Self-hosted is the explicit fallback path. The SDK only attempts to spawn pmxt-core when no API key is configured.
The result: the shortest correct config is hosted. A single env var (PMXT_API_KEY) plus a constructor with a wallet and private key is everything you need to trade.
# Minimum hosted trading config:
import os
os.environ["PMXT_API_KEY"] = "pmxt_live_..."

client = pmxt.Polymarket(
    wallet_address="0x...",
    private_key="0x...",
)

Self-hosted fallback (advanced)

If you have specific reasons to run local — sub-100ms latency, raw venue credentials, regulatory custody — drop the API key. See Self-hosted for the full guide and Server Management for lifecycle controls.
# Self-hosted: no PMXT_API_KEY, no pmxt_api_key arg
client = pmxt.Polymarket(private_key="0x...")

See also