Retrieving feature flags and flag groups through various access methods and formats
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.
Access individual flags using the flag name as the URL path. FlagFlow supports multiple output formats to suit different integration needs:
Returns the flag value in hierarchical JSON structure:
# Request GET http://localhost:3000/flag/accounting/huf/ff_allow_exchange # Response { "accounting": { "huf": { "ff_allow_exchange": false } } }
Returns flag value in environment variable format:
# Request GET http://localhost:3000/flag/accounting/huf/ff_allow_exchange?format=env # Response accounting/huf/ff_allow_exchange=false
Returns only the flag value as plain text:
# Request GET http://localhost:3000/flag/accounting/huf/ff_allow_exchange?format=plain # Response false
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.
Returns all flag values within a hierarchy as structured JSON (only contains the subset under the requested path):
# Request - Access all UI flags GET http://localhost:3000/flags/ui # Response { "dashboard": { "new_layout": true, "dark_mode": false, "widget_count": 6 } }
Returns all flags in the group as environment variables:
# 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
FlagFlow uses predictable URL patterns for flag access:
Access Type | URL Pattern | Example 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 |
# 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
// 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
#!/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"
# 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
Explore these related topics for comprehensive FlagFlow usage:
Understand different flag types and their constraints to properly handle returned values.
Learn how to organize flags hierarchically for efficient group access and management.
Generate type-safe clients for accessing flags with full IntelliSense support.
Understand which operations require authentication versus public flag reading access.