Skip to main content

SDK Catalog

Mida provides server-side and native mobile SDKs for experiments and feature flags. Each SDK exposes the same core methods: getExperiment, setEvent, and isFeatureEnabled (plus setAttribute where applicable).

All SDKs are open source under the MIT license and hosted in the mida-so GitHub organization.


Available SDKs

Language / PlatformInstallGitHub
Node.jsnpm install mida-nodemida-so/mida-node
Pythonpip install mida-pythonmida-so/mida-python
PHPcomposer require mida-so/mida-phpmida-so/mida-php
Rubygem install mida-rubymida-so/mida-ruby
iOS (Swift)Swift Package Manager — see READMEmida-so/mida-ios-sdk
Android (Kotlin)Gradle module — see READMEmida-so/mida-android-sdk
FlutterAdd to pubspec.yaml — see READMEmida-so/mida-flutter

Native mobile (iOS and Android)

Use the iOS or Android SDK when you run experiments inside a native app (no browser script). Both call the Mida API with the same experiment keys and variant names (Control, Variant 1, …) as server-side web backends.

iOS (Swift)

  • Requirements: Swift 5.7+, iOS 13+ / macOS 10.15+
  • Install: In Xcode, File → Add Package Dependencies… and add mida-so/mida-ios-sdk, or add the package by local path in Package.swift.
  • APIs: async/awaitgetExperiment, setEvent, setAttribute, isFeatureEnabled, getFeatureFlags
import Mida

let mida = Mida(projectKey: "YOUR_PROJECT_KEY")
let variant = await mida.getExperiment(experimentKey: "checkout-flow", distinctId: userId)

Android (Kotlin)

  • Requirements: minSdk 21, Kotlin 1.9+, Kotlin coroutines
  • Install: Include the mida library module from mida-so/mida-android-sdk in your Gradle project (implementation(project(":mida"))). See the repo README for settings.gradle.kts setup.
  • APIs: suspend functions — getExperiment, setEvent, setAttribute, isFeatureEnabled, getFeatureFlags
import so.mida.sdk.Mida

val mida = Mida(projectKey = "YOUR_PROJECT_KEY")
lifecycleScope.launch {
val variant = mida.getExperiment("checkout-flow", userId)
}
Flutter

For cross-platform apps, use the Flutter SDK instead of wiring both native SDKs separately.


Core API (all SDKs)

All SDKs share the same method names and argument shapes. Language-specific syntax varies — see each README for full examples.

Initialize

// Node.js
const Mida = require('mida-node');
const mida = new Mida('YOUR_PROJECT_KEY');

Create one instance per application, not per request.


getExperiment(experimentKey, distinctId)

Returns the variant name assigned to this user for the given experiment.

ArgumentTypeDescription
experimentKeystringThe experiment key from the dashboard
distinctIdstringA stable unique identifier for the user

Returns: 'Control', 'Variant 1', 'Variant 2', … or null if the user is not in the experiment (outside traffic allocation, targeting rules, etc.)

const variant = await mida.getExperiment('checkout-flow-v2', userId);

if (variant === 'Control') {
// original
} else if (variant === 'Variant 1') {
// treatment
}
null means not bucketed

Always handle the null / falsy case — the user may be outside the traffic split or the experiment may not be live yet.


setEvent(eventName, distinctId [, properties])

Records a conversion event for a user. The eventName must match the goal name configured in the Mida dashboard.

ArgumentTypeDescription
eventNamestringName of the event (must match the dashboard goal)
distinctIdstringSame stable user ID passed to getExperiment
propertiesobjectOptional. Include revenue, quantity, currency for purchase events
// Custom event
await mida.setEvent('signup_completed', userId);

// Purchase / revenue
await mida.setEvent('Purchase', userId, {
revenue: 49.99,
quantity: 1,
currency: 'USD'
});

isFeatureEnabled(featureKey [, distinctId])

Returns true or false for a feature flag. Useful for gradual rollouts and kill switches without a full A/B split.

const enabled = await mida.isFeatureEnabled('new-checkout', userId);

if (enabled) {
// show new checkout
}

setAttribute(distinctId, attributes)

Sets user attributes that can be used for targeting and segmentation in the dashboard.

await mida.setAttribute(userId, {
plan: 'pro',
country: 'US',
company: 'Acme Corp'
});

Using the same user ID everywhere

The distinctId is the bucketing key — Mida hashes it with the experiment key to deterministically assign a variant. Use the same value across all SDK calls for a user:

  • A database user ID (e.g. 42, or 'user_42') is the most stable choice
  • For anonymous visitors, generate a UUID on first visit and persist it (cookie, local storage, or session)
  • Do not use email addresses — they can change

Combining server-side bucketing with client-side goal tracking

If the conversion event happens on a webpage (e.g. a thank-you page after checkout), you can track it client-side through the Mida browser script instead of calling setEvent() from your server. Both approaches write to the same goal table and appear in the same dashboard results.


Self-hosted script

If you prefer to self-host the Mida frontend tracking script rather than loading it from cdn.mida.so, the source is available at mida-so/mida-script.


Need a language that's not listed?

Open an issue in the closest SDK repo or contact hello@mida.so. The bucketing algorithm is deterministic and straightforward to port — contributions are welcome.