On this page

Python Core SDK Migration Guide

Migrate from the legacy Python Server SDK to the new Python Core SDK

Why migrate?

  • Performance: Python Core evaluates faster than the legacy SDK
  • New Features: Access to Parameter Stores, CMAB (Contextual Multi-Armed Bandits), observabilityClient, and more
  • Future support: All new features and improvements are available only in Python Core
  • Maintenance: The legacy Python SDK is in maintenance mode and receives only critical bug fixes

Installation

pip install statsig-python-core

StatsigUser

User creation is the same in the new Python Core SDK.

from statsig_python_core import *

user = StatsigUser(
    user_id="user_123",
    email="user@example.com",
    ip="192.168.0.1",
    user_agent="Mozilla/5.0",
    country="US",
    custom={
        "subscription_level": "premium"
    }
)

API changes

Key package and class changes

For more details on the new API, go to the Python Core SDK documentation.

Behavioral changes

StatsigOptions changes

The table below shows the mapping between legacy SDK options and Server Core SDK options:

  1. Add the new Dependencies

    • Add the new SDK package/module and any required platform-specific dependencies for your environment.
    • Update import or require statements to reference the new SDK namespace or module.
    • Keep the old package in place for now. Having both packages running in parallel during local testing can be useful. If needed (depending on the language), you may want to alias the new package.
  2. Update Initialization

    • Switch to the new initialization syntax. New SDK keys aren't required. If you update them, ensure they have the same target apps.
    • Use the appropriate builder or configuration pattern for setting options. Migrate the StatsigOptions you use, because some were renamed.
  3. Update User Creation

    • Migrate to the new format for creating user objects.
    • If needed, use the builder pattern or updated constructor to set user properties.
  4. Update Method Calls

    • Starting with a few calls, switch your config checks from the old SDK to the new SDK, replacing oldStatsig.getExperiment() with newStatsig.getExperiment().
    • After changing the package usage, test your service locally or with existing test patterns to build confidence in the new SDK's behavior.
    • As you migrate additional calls, update method names that changed (notably, get_config() to get_dynamic_config()).
    • After you're comfortable with the call-by-call migration, consider using refactoring tools to migrate the remaining calls in bulk.
  5. Test Thoroughly

    • Verify that all configs are successfully migrated. Run your test suites end-to-end.
  6. Remove old SDK

    • Remove references to the old SDK. Clean up old initialization and import logic.

Additional option: gradual migration using adapter

  • Use a migration adapter to wrap the new SDK with the old interface.
  • This approach allows incremental migration without updating all call sites at once.
  • Python Core Migration Adapter

Need help?

If you encounter issues during migration, contact:

Was this helpful?