Skip to main content
The PMXT SDKs manage a local sidecar server automatically. When you create an exchange instance without a hosted API key, the SDK spawns a sidecar process, waits for it to become healthy, and routes every request through it. The server namespace gives you explicit control over that sidecar lifecycle.

Quick reference

MethodDescription
server.start()Start the sidecar if it is not already running (idempotent).
server.stop()Stop the running sidecar (SIGTERM + lock file cleanup).
server.restart()Stop then start.
server.status()Structured snapshot: running, pid, port, version, uptime.
server.health()true/True if /health responds OK, false/False otherwise.
server.logs(n)Last n lines from ~/.pmxt/server.log (default 50).

Start

Idempotent. If the sidecar is already running and healthy, returns immediately. Otherwise spawns pmxt-ensure-server and waits for the health check.
import pmxt

pmxt.server.start()
You rarely need to call start() yourself — creating an exchange instance (e.g. pmxt.Polymarket()) calls it automatically.

Stop

Reads the lock file at ~/.pmxt/server.lock, sends SIGTERM to the sidecar process, and removes the lock file.
pmxt.server.stop()

Restart

Equivalent to stop() followed by start().
pmxt.server.restart()

Status

Returns a structured snapshot of the sidecar state. A new object is returned on every call (no shared mutable references).
info = pmxt.server.status()
print(info)
# {
#   "running": True,
#   "pid": 4242,
#   "port": 3847,
#   "version": "2.30.9",
#   "uptime_seconds": 3612.5,
#   "lock_file": "/Users/you/.pmxt/server.lock"
# }
FieldTypeDescription
runningboolWhether the sidecar is alive and responding to /health.
pidint | nullProcess ID from the lock file.
portint | nullPort the sidecar is listening on (default 3847).
versionstring | nullServer version from the lock file.
uptime_seconds / uptimeSecondsfloat | nullSeconds since the lock file was written.
lock_file / lockFilestringAbsolute path to ~/.pmxt/server.lock.

Health

Returns true/True if the sidecar’s /health endpoint responds with {"status": "ok"}, false/False otherwise.
if pmxt.server.health():
    print("sidecar is up")

Logs

Returns the last n lines from ~/.pmxt/server.log. Defaults to 50. Returns an empty list/array if the log file does not exist.
for line in pmxt.server.logs(20):
    print(line)

Deprecated aliases

The top-level stop_server() / stopServer() and restart_server() / restartServer() functions still work but emit deprecation warnings. Use the server namespace instead.
# Old (deprecated)
pmxt.stop_server()

# New
pmxt.server.stop()

Environment variables

VariableEffect
PMXT_ALWAYS_RESTART=1Force-restart the sidecar on every ensure_server_running / ensureServerRunning call (useful during development).