Skip to main content

Reflex custom component wrapping @tryvital/vital-link and integrating the Junction (Vital) health data SDK

Project description

CI PyPI Python License: MIT Docs

reflex-junction

A Reflex custom component for integrating Junction (Vital) health data into your application. Connect wearables and health platforms (Oura, Fitbit, Apple Health, Garmin, etc.) with a few lines of Python.

Features

  • JunctionState — Reflex state management for the Vital API (user creation, provider connections, data refresh)
  • JunctionUser — Extended state with health data summaries (activity, sleep, body, meals, workouts)
  • wrap_app() — One-line integration that configures your entire Reflex app
  • junction_provider() — Component-level integration for wrapping specific pages
  • Webhook support — FastAPI router for receiving real-time health data events
  • Link widget support — Token generation for the Vital Link provider connection UI
  • Multi-region — US and EU sandbox/production environments

Installation

pip install reflex-junction

Or with your preferred package manager:

uv add reflex-junction
poetry add reflex-junction

Quick Start

1. Get an API key

Sign up at tryvital.io and grab your API key from the dashboard.

2. Wrap your app

import os
import reflex as rx
import reflex_junction as junction

app = rx.App()

junction.wrap_app(
    app,
    api_key=os.environ["JUNCTION_API_KEY"],
    environment="sandbox",  # or "production"
    register_user_state=True,
)

3. Use Junction state in your pages

def health_dashboard() -> rx.Component:
    return rx.container(
        rx.heading("Health Dashboard"),
        rx.text(f"Connected: {junction.JunctionState.has_connections}"),
        rx.foreach(
            junction.JunctionState.connected_sources,
            lambda p: rx.badge(p["name"]),
        ),
    )

Usage

Using junction_provider directly

For page-level integration instead of app-wide:

import reflex_junction as junction

def health_page() -> rx.Component:
    return junction.junction_provider(
        rx.container(
            rx.text("Connected providers: "),
            rx.text(junction.JunctionState.connected_sources.length()),
        ),
        api_key=os.environ["JUNCTION_API_KEY"],
    )

Webhook support

Receive real-time events when health data updates:

junction.wrap_app(
    app,
    api_key=os.environ["JUNCTION_API_KEY"],
    register_webhooks=True,
    webhook_secret=os.environ["JUNCTION_WEBHOOK_SECRET"],
    webhook_prefix="/junction",  # POST /junction/webhooks
)

Environment options

Environment Description
sandbox US sandbox (default)
production US production
sandbox_eu EU sandbox
production_eu EU production

API Reference

State Classes

Class Description
JunctionState Core state — user creation, provider management, Link tokens
JunctionUser Extended state — health data summaries (activity, sleep, body, meals, workouts)

Configuration Models

Class Description
JunctionConfig Environment and region settings
LinkConfig Redirect URL and provider filter for the Link widget
ProviderInfo Provider metadata (name, slug, logo, auth_type)

Functions

Function Description
wrap_app(app, api_key, ...) One-line app integration with optional webhooks
junction_provider(*children, api_key, ...) Component wrapper for page-level integration
on_load(handlers) Wrap page on_load handlers to wait for Junction init
register_on_auth_change_handler(handler) Register handler to fire after Junction initializes
create_webhook_router(prefix, secret) Create a standalone FastAPI webhook router
register_webhook_api(app, secret, prefix) Register webhook endpoint on a Reflex app

JunctionState Events

Event Description
create_user(client_user_id) Create a Junction user mapped to your app's user
get_connected_providers() Fetch connected health data providers
disconnect_provider(provider) Disconnect a specific provider by slug
refresh_data() Trigger data sync from all connected providers
create_link_token(redirect_url) Generate a Link widget token

See the full documentation for detailed guides.

Contributing

Contributions welcome! We use Taskfile for common tasks:

task install          # Install dev dependencies + pre-commit
task test             # Run lint + typecheck + pytest
task run              # Run the demo app
task run-docs         # Serve docs locally at localhost:9000
task bump-patch       # Bump patch version (bug fix)
task bump-minor       # Bump minor version (new feature)

Workflow: Fork → feature branch → add tests → submit PR.

License

MIT — Copyright (c) 2025 Syntropy Health

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

reflex_junction-0.1.0.tar.gz (123.7 kB view details)

Uploaded Source

Built Distribution

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

reflex_junction-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file reflex_junction-0.1.0.tar.gz.

File metadata

  • Download URL: reflex_junction-0.1.0.tar.gz
  • Upload date:
  • Size: 123.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for reflex_junction-0.1.0.tar.gz
Algorithm Hash digest
SHA256 49db60547fbfd060001d2a0c283870caba4697a03ce94d0db6603593e2a98abd
MD5 35f52d1ba0e7cf94bcd051a93106fb5d
BLAKE2b-256 017ca97bb73e71af309c8a3a6a575838e68ad7ea57b2e7e215ec85f967d2c51f

See more details on using hashes here.

File details

Details for the file reflex_junction-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: reflex_junction-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.14 {"installer":{"name":"uv","version":"0.9.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for reflex_junction-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c80d2edc1b5e6d9b895ac155a47336525b29122275e4346e9d34b72ec6235a15
MD5 5dbafe94036158f89a35660e1bc6d0f8
BLAKE2b-256 a1aac43273d6ac0264be5aef6b9eeeffc58b9ceba63d56c90bf6c6ed3be5b512

See more details on using hashes here.

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