Skip to main content

Firebase Remote Config SDK

Project description

Firebase Remote Config SDK for Python

A Python SDK for managing Firebase Remote Config, built as a typed abstraction over the Firebase REST API. This package provides a convenient way to get, validate, update and upload remote config templates.

Features

  • Provides SDK for managing Remote Config for mobile clients that is missing from Google firebase-admin package
  • Type-safe interface using Pydantic models
  • Minimal DSL for building and manipulating condition expressions
  • Enables parsing condition expressions into Pydantic models

Capabilities

  • Fetch and update Remote Config templates
  • Validate template updates before deployment
  • List template versions and perform rollbacks
  • Add, query, and update conditions and parameters
  • Serialize and parse condition expressions to/from structured form

Installation

pip install firebase-remote-config

Requirements

  • Python 3.9 or higher
  • Firebase project with Remote Config enabled
  • Service account credentials with necessary permissions (Firebase Admin / Firebase Remote Config Admin)

Usage

Getting Started

First, initialize the client with your Firebase credentials:

from google.oauth2 import service_account
from firebase_remote_config import RemoteConfigClient

# Initialize the client
credentials = service_account.Credentials.from_service_account_file('path/to/service-account.json')
client = RemoteConfigClient(credentials, 'your-project-id')

# Get current Remote Config template
config = client.get_remote_config()

# Upload template to Firebase Remote Config
updated_config = client.update_remote_config(config)

Use Cases

1. Creating and Updating Parameters

import firebase_remote_config as rc

# Add new parameter to the remote config template
new_param = rc.RemoteConfigParameter(
    defaultValue=rc.RemoteConfigParameterValue(value="default_value"),
    valueType=rc.ParameterValueType.STRING,
    description="A new parameter"
)
config.template.parameters["new_parameter"] = new_param

# find parameter in the template
param = config.find_param_by_key("new_parameter")
param.description = "My new parameter"

2. Working with Conditional Values

import firebase_remote_config as rc

# Create condition object
condition = rc.RemoteConfigCondition(
    name="ios_users",
    expression="device.os == 'ios'",
    tagColor=rc.TagColor.BLUE,
)

# Insert condition to rconfig template
config.insert_condition(condition)

# Use newly created condition in a conditional value
config.set_conditional_value(
    param_key="my_parameter",
    param_value=rc.RemoteConfigParameterValue(value="my_value"),
    param_value_type=rc.ParameterValueType.STRING,
    condition_name="ios_users",
)

3. Building Complex Conditions with ConditionBuilder

import firebase_remote_config as rc
from firebase_remote_config.conditions import ConditionBuilder

# Create a complex condition
builder = ConditionBuilder()
builder.CONDITION().APP_VERSION().GTE("1.2.0")
builder.CONDITION().APP_USER_PROPERTY("total_purchases_usd").GTE(5)
builder.CONDITION().DEVICE_COUNTRY().IN(["US", "CA"])
cond_expr = builder.build()

# Serialize condition as string
cond_expr_str = str(cond_expr)
# app.version.>=(['1.2.0']) && app.userProperty['total_purchases_usd'] >= 5 && device.country in ['US', 'CA']

# Insert condition to remote config template
config.insert_condition(rc.RemoteConfigCondition(
    name="active_premium_users",
    expression=cond_expr_str,
    tagColor=rc.TagColor.GREEN,
))

4. Parsing condition expression

from firebase_remote_config.conditions import ConditionParser

# Parse condition expression
parser = ConditionParser()
cond_expr = "dateTime >= dateTime('2025-01-01T09:00:00') && app.userProperty['my_property'].contains(['abc', 'def'])"
condition = parser.parse(cond_expr)

# Compare string representations of the condition to the original expression
print(str(condition) == cond_expr)
# True

5. Version Management

# List recent versions
versions, _ = client.list_versions(page_size=30)

# Rollback to a previous version
rolled_back_config = client.rollback(version_number="42")

License

This project is licensed under the terms of the LICENSE file in the root of this repository.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firebase_remote_config-0.1.9.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

firebase_remote_config-0.1.9-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file firebase_remote_config-0.1.9.tar.gz.

File metadata

  • Download URL: firebase_remote_config-0.1.9.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for firebase_remote_config-0.1.9.tar.gz
Algorithm Hash digest
SHA256 09fc704ca0ab18833ab4de5a8233923e2e7bef5036e4573a9eb43f3f81d4b1ef
MD5 d4b84a09cfda2900b76e2706580cd00d
BLAKE2b-256 08b26654132f61c419590c06e3658c383765b10e1f7d7837c8987c39fd835cbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for firebase_remote_config-0.1.9.tar.gz:

Publisher: publish.yml on apprevenew-com/firebase-remote-config-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file firebase_remote_config-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for firebase_remote_config-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 fbea9be0e29d82a298ac7aad2c0800b0a112ca520232ecf3dfd33eda2be54d18
MD5 ca32d2d86ce482db1ef9b640d864e53a
BLAKE2b-256 9753e3533df7c4b798f1156f849957bab50189dda212c08968863e118ef3faff

See more details on using hashes here.

Provenance

The following attestation bundles were made for firebase_remote_config-0.1.9-py3-none-any.whl:

Publisher: publish.yml on apprevenew-com/firebase-remote-config-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page