Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

Mida Python Client

This repository contains a Python client for interacting with the Mida.so.

Installation

Clone the repository:

git clone https://github.com/mida-so/mida-python.git

Install the required dependencies:

pip install requests

Usage

Import the Mida class to your Python project. Create an instance of Mida using the project key from your Mida.so account. Use the available methods to interact with the Mida API. Example usage:

frommidaimportMida# replace 'your-project-key' with your actual keymida_instance=Mida('your-project-key')
# replace 'your-experiment-key' and 'your-distinct-id' with actual valuesexperiment=mida_instance.get_experiment('your-experiment-key', 'your-distinct-id')
ifexperiment=='Control':
print('Control variant execute')
elifexperiment=='Variant 1':
print('Variant 1 variant execute')
elifexperiment=='Variant 2':
print('Variant 2 variant execute')
# set an eventmida_instance.set_event('event_name', 'your-distinct-id')
# reload feature flags for a usermida_instance.on_feature_flags('your-distinct-id')
# check if a feature flag is enabledis_enabled=mida_instance.is_feature_enabled('feature_flag_key')
ifis_enabled:
print('Feature flag is enabled')
else:
print('Feature flag is disabled')
# set user attributesattributes= {
'name': 'John Doe',
'email': 'john@example.com'
}
mida_instance.set_attribute('your-distinct-id', attributes)

Methods

  • get_experiment(experiment_key, distinct_id): Retrieves the assigned variant for the specified experiment and user.
  • set_event(event_name, distinct_id): Sets an event for the specified user.
  • is_feature_enabled(key): Checks if a specific feature flag is enabled for the current user.
  • on_feature_flags(distinct_id): Reloads the feature flags for the specified user.
  • set_attribute(distinct_id, properties): Sets user attributes for the specified user with the given properties.

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvement, please create a pull request.

Support

For support, please contact us at hello@mida.so.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

Mida server-side A/B Testing and Feature Flagging for Python. Start for free up to 50,000 MTU.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages