Back to Docs

SDK Documentation

Official SDKs for JavaScript, Go, Python, and Ruby. Install, initialize, and start evaluating feature flags in minutes.

JavaScript / TypeScript

@buildrflags/sdk
Full TypeScript typesIn-memory cache (60s TTL)Automatic retriesNode.js 18+

Installation

npm install @buildrflags/sdk

Initialization

init.ts
import { createClient } from '@buildrflags/sdk';

const client = createClient({
  apiKey: 'bf_production_xxxxxxxx',
});

Evaluate a Flag

evaluate.ts
const enabled = await client.isEnabled('new-feature', {
  userId: 'user-123',
  attributes: { plan: 'pro' },
});

if (enabled) {
  // Show the new feature
}

Get All Flags

all-flags.ts
const results = await client.evaluateAll(
  ['feature-a', 'feature-b'],
);

for (const [key, result] of results) {
  console.log(key, result.enabled);
}

Go

github.com/buildrlab/buildrflags-go
Zero dependencies (stdlib only)Thread-safe cacheContext-awareGo 1.21+

Installation

go get github.com/buildrlab/buildrflags-go

Initialization

init.go
import buildrflags "github.com/buildrlab/buildrflags-go"

client, err := buildrflags.NewClient("bf_production_xxxxxxxx")
if err != nil {
    log.Fatal(err)
}
defer client.Close()

Evaluate a Flag

evaluate.go
enabled, err := client.IsEnabled(ctx, "new-feature",
    &buildrflags.EvalContext{
        UserID: "user-123",
        Attributes: map[string]interface{}{
            "plan": "pro",
        },
    },
)

if enabled {
    // Show the new feature
}

Get All Flags

all-flags.go
results, err := client.EvaluateAll(ctx, nil)
for key, result := range results {
    fmt.Printf("%s: %v\n", key, result.Enabled)
}

Python

buildrflags
Context manager supportThread-safe cacheAutomatic retriesPython 3.9+

Installation

pip install buildrflags

Initialization

init.py
from buildrflags import BuildrFlagsClient

client = BuildrFlagsClient(
    api_key="bf_production_xxxxxxxx"
)

Evaluate a Flag

evaluate.py
from buildrflags import EvaluationContext

result = client.evaluate("new-feature",
    context=EvaluationContext(
        user_id="user-123",
        attributes={"plan": "pro"},
    ),
)

if result.enabled:
    # Show the new feature

Get All Flags

all-flags.py
flags = client.evaluate_all()
for key, result in flags.items():
    print(f"{key}: {'ON' if result.enabled else 'OFF'}")

Ruby

buildrflags
Thread-safe (Puma compatible)Built-in cachingNo external dependenciesRuby 3.0+

Installation

gem install buildrflags

Initialization

init.rb
require "buildrflags"

client = BuildrFlags::Client.new(
  api_key: "bf_production_xxxxxxxx"
)

Evaluate a Flag

evaluate.rb
result = client.evaluate("new-feature",
  context: {
    user_id: "user-123",
    attributes: { plan: "pro" },
  }
)

if result.enabled
  # Show the new feature
end

Get All Flags

all-flags.rb
flags = client.evaluate_all
flags.each do |key, result|
  puts "#{key}: #{result.enabled}"
end