Other Languages

Use standard OpenFeature OFREP providers for unsupported languages

No official Flipswitch SDK for your language? Use any standard OpenFeature OFREP provider.

Standard OFREP providers work with Flipswitch but don't include SSE for real-time updates. For instant flag changes, use an official SDK where available.

When to Use OFREP

  • Your language doesn't have an official Flipswitch SDK
  • You only need polling-based flag evaluation
  • You want to minimize dependencies
  • You're building a proof-of-concept

.NET

using OpenFeature;
using OpenFeature.Contrib.Providers.Ofrep;
 
var provider = new OFREPProvider(new OFREPProviderOptions
{
    BaseUrl = "https://api.flipswitch.dev",
    Headers = new Dictionary<string, string>
    {
        ["X-API-Key"] = "YOUR_API_KEY"
    }
});
 
await Api.Instance.SetProviderAsync(provider);
var client = Api.Instance.GetClient();
 
var darkMode = await client.GetBooleanValueAsync("dark-mode", false);

PHP

use OpenFeature\OpenFeatureAPI;
use OpenFeature\Contrib\Providers\OFREP\OFREPProvider;
 
$provider = new OFREPProvider([
    'baseUrl' => 'https://api.flipswitch.dev',
    'headers' => [
        'X-API-Key' => 'YOUR_API_KEY'
    ]
]);
 
$api = OpenFeatureAPI::getInstance();
$api->setProvider($provider);
$client = $api->getClient();
 
$darkMode = $client->getBooleanValue('dark-mode', false);

Ruby

require 'openfeature/sdk'
require 'openfeature/contrib/providers/ofrep'
 
provider = OpenFeature::Contrib::Providers::OFREP.new(
  base_url: 'https://api.flipswitch.dev',
  headers: { 'X-API-Key' => 'YOUR_API_KEY' }
)
 
OpenFeature::SDK.configure do |config|
  config.set_provider(provider)
end
 
client = OpenFeature::SDK.build_client
dark_mode = client.fetch_boolean_value(flag_key: 'dark-mode', default_value: false)

Rust

use open_feature::{OpenFeature, EvaluationContext};
use open_feature_ofrep::OFREPProvider;
 
let provider = OFREPProvider::new(
    "https://api.flipswitch.dev",
    Some("YOUR_API_KEY"),
);
 
let mut api = OpenFeature::singleton_mut().await;
api.set_provider(provider).await;
 
let client = api.create_client();
let dark_mode = client.get_bool_value("dark-mode", Some(&context), None).await?;

Direct OFREP API

If there's no OFREP provider for your language, call the API directly.

Single Flag Evaluation

curl -X POST https://api.flipswitch.dev/ofrep/v1/evaluate/flags/dark-mode \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "context": {
      "targetingKey": "user-123",
      "email": "user@example.com"
    }
  }'

Response:

{
  "key": "dark-mode",
  "value": true,
  "variant": "enabled",
  "reason": "TARGETING_MATCH"
}

Bulk Evaluation

curl -X POST https://api.flipswitch.dev/ofrep/v1/evaluate/flags \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"context": {"targetingKey": "user-123"}}'

Response:

{
  "flags": [
    {"key": "dark-mode", "value": true, "variant": "enabled", "reason": "TARGETING_MATCH"},
    {"key": "max-items", "value": 50, "variant": "high", "reason": "DEFAULT"}
  ]
}

ETag Support

Use ETags for efficient caching:

# First request returns ETag header
curl -X POST https://api.flipswitch.dev/ofrep/v1/evaluate/flags \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{"context": {"targetingKey": "user-123"}}'
# Response includes: ETag: "abc123"
 
# Subsequent requests with If-None-Match
curl -X POST https://api.flipswitch.dev/ofrep/v1/evaluate/flags \
  -H "X-API-Key: YOUR_API_KEY" \
  -H 'If-None-Match: "abc123"' \
  -d '{"context": {"targetingKey": "user-123"}}'
# Returns 304 Not Modified if unchanged

All Supported Languages

See the OpenFeature ecosystem for OFREP providers in:

  • JavaScript/TypeScript (web and server)
  • Go
  • Java
  • .NET
  • Python
  • PHP
  • Ruby
  • Rust
  • Swift
  • Kotlin

On this page