Access Flags

Retrieving feature flags and flag groups through various access methods and formats

Flag Access Overview

FlagFlow provides flexible access to feature flags through multiple methods and formats. All flag reading operations are publicly accessible without authentication, making integration simple while maintaining security for administrative operations.

Open Access: Flag values can be read freely by any application or service that can reach your FlagFlow instance, enabling easy integration without credential management.

Hierarchical Access: Use flag hierarchy to access specific portions of your flag tree without loading unnecessary data. See Flag Hierarchy for organizational strategies.

Single Flag Access

Access individual flags using the flag name as the URL path. FlagFlow supports multiple output formats to suit different integration needs:

JSON Format

Returns the flag value in hierarchical JSON structure:

JSON Flag Access
# Request
GET http://localhost:3000/flag/accounting/huf/ff_allow_exchange

# Response
{
  "accounting": {
    "huf": {
      "ff_allow_exchange": false
    }
  }
}

Environment Variable Format

Returns flag value in environment variable format:

Environment Variable Format
# Request
GET http://localhost:3000/flag/accounting/huf/ff_allow_exchange?format=env

# Response
accounting/huf/ff_allow_exchange=false

Plain Value Format

Returns only the flag value as plain text:

Plain Value Format
# Request
GET http://localhost:3000/flag/accounting/huf/ff_allow_exchange?format=plain

# Response
false

Flag Group Access

Access multiple related flags by specifying a hierarchy prefix. This is particularly useful for loading all flags within a specific feature area or organizational boundary.

JSON Group Format

Returns all flag values within a hierarchy as structured JSON (only contains the subset under the requested path):

JSON Group Access Example
# Request - Access all UI flags
GET http://localhost:3000/flags/ui

# Response
{
  "dashboard": {
    "new_layout": true,
    "dark_mode": false,
    "widget_count": 6
  }
}

Environment Variable Group Format

Returns all flags in the group as environment variables:

Environment Variable Group Format
# Request
GET http://localhost:3000/flags/ui?format=env

# Response
ui/dashboard/new_layout=true
ui/dashboard/dark_mode=false
ui/dashboard/widget_count=6

URL Structure and Examples

FlagFlow uses predictable URL patterns for flag access:

Access TypeURL PatternExample URL
Single Flag/flag/[flag_name][?format=json|env|plain]http://localhost:3000/flag/accounting/huf/ff_allow_exchange
Flag Group/flags/[prefix][?format=json|env]http://localhost:3000/flags/ui
All Flags/flags[?format=json|env]http://localhost:3000/flags

Common Group Access Examples

Group Access URL Examples
# Access all UI-related flags
http://localhost:3000/flags/ui

# Access all API configuration flags
http://localhost:3000/flags/api

# Access all authentication flags
http://localhost:3000/flags/api/auth

# Access all experimental features
http://localhost:3000/flags/experiments

# Access all flags in environment variable format
http://localhost:3000/flags?format=env

Integration Examples

JavaScript/TypeScript Integration

JavaScript Flag Access
// Fetch a single flag
const response = await fetch('http://localhost:3000/flag/accounting/huf/ff_allow_exchange');
const flagData = await response.json();
const isEnabled = flagData.accounting.huf.ff_allow_exchange;

// Fetch flag group
const groupResponse = await fetch('http://localhost:3000/flags/ui');
const uiFlags = await groupResponse.json();
// uiFlags = { "dashboard": { "new_layout": true, "dark_mode": false, "widget_count": 6 } }

// Using environment variable format for configuration
const envResponse = await fetch('http://localhost:3000/flags/api?format=env');
const envVars = await envResponse.text();
// Parse and set environment variables as needed

Shell Script Integration

Shell Script Integration
#!/bin/bash

# Get a single flag value
ALLOW_EXCHANGE=$(curl -s http://localhost:3000/flag/accounting/huf/ff_allow_exchange?format=plain)

if [ "$ALLOW_EXCHANGE" = "true" ]; then
    echo "Currency exchange allowed"
else
    echo "Currency exchange disabled"
fi

# Load all environment flags as variables (note: paths with slashes in env format)
eval $(curl -s "http://localhost:3000/flags/deployment?format=env")
echo "Deployment timeout: $deployment_timeout"
echo "Max retries: $deployment_max_retries"

Docker Container Integration

Docker Integration
# Dockerfile - Load environment variables from FlagFlow
FROM node:18-alpine

# Install curl for flag fetching
RUN apk add --no-cache curl

# Create startup script
RUN echo '#!/bin/sh' > /startup.sh &&     echo 'eval $(curl -s "$FLAGFLOW_URL/flags/app?format=env")' >> /startup.sh &&     echo 'exec "$@"' >> /startup.sh &&     chmod +x /startup.sh

ENTRYPOINT ["/startup.sh"]
CMD ["npm", "start"]

# Usage:
# docker run -e FLAGFLOW_URL=http://flagflow:3000 myapp

Performance and Optimization

Efficient Access Patterns

  • Use group access to reduce HTTP requests
  • Fetch only needed hierarchy branches
  • Cache flag values with appropriate TTL
  • Use environment variable format for simple configs

Caching Strategies

  • HTTP caching headers are included in responses
  • Implement client-side caching with refresh intervals
  • Use ETags for conditional requests
  • Consider real-time updates via WebSocket for critical flags

Best Practices

  • Graceful Degradation: Always handle cases where FlagFlow is unreachable
  • Default Values: Use sensible defaults when flag values are unavailable
  • Error Handling: Implement proper error handling for network failures
  • Monitoring: Monitor flag access patterns and performance

Related Documentation

Explore these related topics for comprehensive FlagFlow usage:

Flag Types

Understand different flag types and their constraints to properly handle returned values.

Flag Hierarchy

Learn how to organize flags hierarchically for efficient group access and management.

TypeScript Schema

Generate type-safe clients for accessing flags with full IntelliSense support.

Authentication

Understand which operations require authentication versus public flag reading access.

© 2025 FlagFlow All Rights Reserved. llms.txt