Sync metrics and fact tables to GrowthBook
Project description
gbsync
Sync artifacts to GrowthBook using a version-controlled YAML configuration, enabling reproducible deployments and safe collaboration.
Currently supports:
- Fact Tables
- Fact Table Filters
- Fact Metrics
- Environments
Note: gbsync talks directly to the GrowthBook API, so synced resources are flagged as official and cannot be edited from the console — change YAML and re-apply.
Features
- Infrastructure as Code: Define growthbook artifacts in YAML so that it can be version controlled
- Dry-Run Planning: See what will change before applying
- Safe Syncing: Automatic conflict detection and validation
- External File Includes: Organize SQL in separate files
Installation
From PyPI
pip install gbsync
From Source
git clone https://github.com/growthbook/gbsync.git
cd gbsync
pip install -e .
Requirements
- Python 3.12 or higher
- GrowthBook account with API access
- Supported data warehouses: Snowflake, BigQuery, PostgreSQL, MySQL, Redshift, Athena, ClickHouse, MongoDB
Quick Start
1. Get Your API Credentials
- Log into GrowthBook
- Go to Settings → API Keys
- Create a new API key (or copy existing)
- Note the API URL (e.g.,
https://api.growthbook.io)
2. Set Environment Variables
export GB_API_KEY="your_api_key"
export GB_API_URL="https://api.growthbook.io"
3. Create Configuration
Copy the example configuration:
cp examples/gbsync.yaml gbsync.yaml
Edit gbsync.yaml with your datasource ID, SQL, and metrics:
factTables:
- id: fact_events
data:
name: Events
datasource: ds_YOUR_DATASOURCE_ID
userIdTypes: [user_id]
sql: !include fact_tables/events.sql
factMetrics:
- id: metric_conversion_rate
data:
name: Conversion Rate
metricType: ratio
numerator:
factTableId: fact_events
column: conversions
denominator:
factTableId: fact_events
column: total_events
4. Plan Changes
See what will be created/updated/deleted:
gbsync plan
Output:
GrowthBook: Planning changes...
Tables:
✓ Create: Events
Metrics:
✓ Create: Conversion Rate
Ready to apply 2 changes
5. Apply Changes
gbsync apply
Output:
GrowthBook: Planning changes...
Tables:
✓ Create: Events
Metrics:
✓ Create: Conversion Rate
Ready to apply 2 changes
Proceed with apply? [y/N]: y
✓ Applied successfully
Commands
plan
Preview changes without applying them.
gbsync plan [OPTIONS]
Options:
--config, -c: Path to configuration file (default:gbsync.yaml)--api-key: GrowthBook API key (orGB_API_KEYenv var)--api-url: GrowthBook API URL (orGB_API_URLenv var)
Example:
gbsync plan --config ./metrics/prod.yaml
gbsync plan --api-key "sdk-abc123..."
apply
Apply changes to GrowthBook.
gbsync apply [OPTIONS]
Options:
--config, -c: Path to configuration file (default:gbsync.yaml)--api-key: GrowthBook API key (orGB_API_KEYenv var)--api-url: GrowthBook API URL (orGB_API_URLenv var)--auto-approve: Skip confirmation prompt (use with caution)
Example:
gbsync apply
gbsync apply --auto-approve # Dangerous: skips confirmation
Configuration
See examples/gbsync.yaml for an annotated reference covering projects, environments, fact tables, filters, metrics, template variables.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gbsync-1.0.1.tar.gz.
File metadata
- Download URL: gbsync-1.0.1.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ad1ea6650ed2732e554484c1729dab981b6b7170a71fae765647991ab28de84
|
|
| MD5 |
d8bda294d7918429c3b9b09ffe8bc839
|
|
| BLAKE2b-256 |
fa54390781af0d663dfb617706b02ec9429ea0f40995179adda838ae98c7f55a
|
File details
Details for the file gbsync-1.0.1-py3-none-any.whl.
File metadata
- Download URL: gbsync-1.0.1-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
701550b97a070c6c0460b8807fb8d3a89845a11112d51e3c6a87b6e29af84bbd
|
|
| MD5 |
ff3af9c432c10e0c9ab71d1578eac63a
|
|
| BLAKE2b-256 |
c71fc443a6727116843d2cc9049b2eae34e331806eef6318e2f27be1c7053d70
|