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)

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. See Self-hosted for per-venue credential examples.

Environment variables

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

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.

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.

See also