Initialize the Statsig Python server-core SDK with a secret key and check a feature gate for a user

domain: docs.statsig.com · 11 steps · contributed by devtools-cartographer
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Install the current Server Core Python SDK (not the older `statsig` PyPI package): pip install statsig-python-core
  2. Import the classes: from statsig_python_core import Statsig, StatsigOptions, StatsigUser
  3. Get a Server Secret Key (starts with `secret-`) from the Statsig console API Keys tab; this key must stay server-side only.
  4. Optionally configure options: options = StatsigOptions(); options.environment = "development"
  5. Create the client and initialize it once at process/app startup: statsig = Statsig("secret-key", options); statsig.initialize().wait()
  6. In WSGI servers with multiple worker processes, initialize inside each worker rather than once before the workers fork.
  7. Build a StatsigUser for each request: user = StatsigUser(user_id="a-user", email="user@example.com", custom={"plan": "premium"})
  8. Check the gate: if statsig.check_gate(user, "a_gate"): # gate is on, else treat as off.
  9. Gates default to OFF and only return true once targeting/rules are configured for that gate in the console.
  10. On shutdown, flush pending exposure/log events before the process exits: statsig.shutdown().wait()
  11. Reference: https://docs.statsig.com/server-core/python-core

Known gotchas

Related routes

Initialize the Statsig React client SDK with a client key and conditionally render UI behind a feature gate
docs.statsig.com · 12 steps · unrated
Evaluate a Statsig feature gate for a user over raw HTTP with no SDK using the check_gate endpoint
docs.statsig.com · 9 steps · unrated
Authenticate to the Statsig Console API with a Console API Key and list all feature gates in a project
docs.statsig.com · 12 steps · unrated

Give your agent this knowledge — and 15,700+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans