Skip to main content

APIBB Python/CLI Renderer - Frozen v1.0

Project description

APIBB Python Renderer

Frozen v1.0 - 25 November 2025

Python/CLI renderer for APIBB applications. Renders APIBB JSON apps to terminal output following the 7-property contract.

Features

  • ✅ Full 7-property contract support (type, data, value, onChange, trigger, children, style)
  • ✅ Reactive state store with {{path}} templating
  • ✅ Dynamic component loading from CDN
  • ✅ Built-in core components (Text, Button, Input, Container, List, Conditional)
  • ✅ Terminal/CLI rendering
  • ✅ Zero dependencies (except requests for component loading)

Installation

cd renderers/apibb-python
pip install -e .

Or install requirements directly:

pip install -r requirements.txt

Usage

Command Line

python src/index.py path/to/app.json

Python API

from src.index import ApibbRenderer

# Load your app
app = {
    "type": "Container",
    "children": [
        {
            "type": "Text",
            "data": "Hello from APIBB Python!"
        },
        {
            "type": "Button",
            "data": "Click Me"
        }
    ],
    "initialState": {
        "counter": 0
    }
}

# Create renderer
renderer = ApibbRenderer(app)

# Render to string
output = renderer.render()
print(output)

# Update state
renderer.update('counter', 1)

# Re-render
output = renderer.render()
print(output)

Built-in Components

Text

{
    "type": "Text",
    "data": "Hello, {{user.name}}!"
}

Button

{
    "type": "Button",
    "data": "Click Me"
}

Renders as: [Click Me]

Input

{
    "type": "Input",
    "data": "Enter your name",
    "value": "{{user.name}}"
}

Renders as: <John> or <Enter your name...>

Container

{
    "type": "Container",
    "children": [
        {"type": "Text", "data": "Child 1"},
        {"type": "Text", "data": "Child 2"}
    ]
}

List

{
    "type": "List",
    "data": ["Apple", "Banana", "Cherry"],
    "children": [
        {"type": "Text", "data": "{{item}}"}
    ]
}

Conditional

{
    "type": "Conditional",
    "data": "{{showContent}}",
    "children": [
        {"type": "Text", "data": "This shows when true"}
    ]
}

Store & Templating

The renderer includes a reactive store that supports {{path}} templating:

renderer = ApibbRenderer(app)

# Set values
renderer.update('user.name', 'Alice')
renderer.update('counter', 5)

# Get values
name = renderer.get('user.name')  # 'Alice'

# Templates are resolved automatically during render
# "Hello, {{user.name}}!" becomes "Hello, Alice!"

Dynamic Component Loading

Components not in the built-in set are automatically loaded from GitHub:

https://raw.githubusercontent.com/Devignite25/apibb/main/v1/components/{ComponentName}/package.zip

The package is downloaded, verified, and cached automatically.

Example Apps

Counter App

counter_app = {
    "type": "Container",
    "children": [
        {
            "type": "Text",
            "data": "Count: {{counter}}"
        },
        {
            "type": "Button",
            "data": "Increment"
        }
    ],
    "initialState": {
        "counter": 0
    }
}

renderer = ApibbRenderer(counter_app)
print(renderer.render())
# Output:
# Count: 0
# [Increment]

renderer.update('counter', 1)
print(renderer.render())
# Output:
# Count: 1
# [Increment]

Todo List

todo_app = {
    "type": "Container",
    "children": [
        {
            "type": "Text",
            "data": "My Todos"
        },
        {
            "type": "List",
            "data": ["{{todos}}"],
            "children": [
                {"type": "Text", "data": "- {{item.text}}"}
            ]
        }
    ],
    "initialState": {
        "todos": [
            {"text": "Learn APIBB"},
            {"text": "Build an app"},
            {"text": "Deploy it"}
        ]
    }
}

renderer = ApibbRenderer(todo_app)
print(renderer.render())
# Output:
# My Todos
# - Learn APIBB
# - Build an app
# - Deploy it

Architecture

The Python renderer follows the same architecture as the React renderer:

  1. Store - Global reactive state with {{path}} resolution
  2. Component Classes - Each component type has a Python class
  3. Dynamic Loading - Components loaded from CDN when needed
  4. Node Rendering - Recursive rendering of the app tree

Limitations

  • Terminal/CLI only (no GUI)
  • No interactive input (read-only rendering)
  • Limited styling (terminal constraints)
  • Synchronous rendering only

Future Enhancements

For interactive CLI apps, consider integrating with:

  • rich - Rich text and beautiful formatting
  • textual - Terminal user interfaces
  • prompt_toolkit - Interactive prompts
  • curses - Full-screen terminal apps

License

APIBB v1.0 Python Renderer - Frozen 25 November 2025

Part of the APIBB v1.0 specification.

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

apibb_python-1.0.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

apibb_python-1.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file apibb_python-1.0.0.tar.gz.

File metadata

  • Download URL: apibb_python-1.0.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for apibb_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c367525ec7e45d90274c674e96bb832233ef6e9dac2cf23eb77a3b1b5ffc55ce
MD5 345bd5509c5ef4914b9d23b83ff32438
BLAKE2b-256 a4432e10a8f9f7ed849405892fee2440d093fa824ab39e73bc0bec17cce42c0b

See more details on using hashes here.

File details

Details for the file apibb_python-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: apibb_python-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for apibb_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 811da013edf280b90153a67f4b61b2e22b1b5ca3e6b1165c9968f957504ee758
MD5 f272ce30f62b32998e3898a07333762b
BLAKE2b-256 0ad6ddaa924abcb6c46498df7d6d5fae09ee36461833bbb6206e72788d7deb7b

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