Skip to main content

Fluent builder API for Adaptive Cards

Project description

FluentCards — Python

CI PyPI Python License: MIT

A Python library for building Adaptive Cards using a fluent builder pattern with strong typing and built-in schema validation.

Also available for .NET (NuGet), Node.js (npm), and Go.

Installation

pip install fluent-cards

Quick Start

from fluent_cards import AdaptiveCardBuilder, TextSize, TextWeight, to_json

card = (AdaptiveCardBuilder.create()
    .with_version('1.5')
    .add_text_block(lambda tb: tb
        .with_text('Hello, FluentCards!')
        .with_size(TextSize.Large)
        .with_weight(TextWeight.Bolder)
        .with_wrap(True))
    .add_action(lambda a: a
        .open_url('https://adaptivecards.io')
        .with_title('Learn More'))
    .build())

print(to_json(card))

Output:

{
  "type": "AdaptiveCard",
  "version": "1.5",
  "body": [
    {
      "type": "TextBlock",
      "text": "Hello, FluentCards!",
      "size": "Large",
      "weight": "Bolder",
      "wrap": true
    }
  ],
  "actions": [
    {
      "type": "Action.OpenUrl",
      "url": "https://adaptivecards.io",
      "title": "Learn More"
    }
  ]
}

Features

  • Fluent builder API — chainable, readable card construction
  • Strong typing — enums for all Adaptive Cards schema values (TextSize, TextWeight, Colors, ContainerStyle, etc.)
  • Built-in validation — catches schema errors before the card is sent
  • Zero dependencies — pure Python, no third-party packages required
  • Full schema support — TextBlock, Image, ColumnSet, Container, FactSet, ActionSet, and more

More Examples

Card with image and actions

from fluent_cards import AdaptiveCardBuilder, TextSize, TextWeight, ActionStyle

card = (AdaptiveCardBuilder.create()
    .with_version('1.5')
    .add_text_block(lambda tb: tb
        .with_text('Order Confirmed')
        .with_size(TextSize.Large)
        .with_weight(TextWeight.Bolder))
    .add_text_block(lambda tb: tb
        .with_text('Your order #12345 has been placed.')
        .with_wrap(True))
    .add_action(lambda a: a
        .open_url('https://example.com/track/12345')
        .with_title('Track Order'))
    .build())

Card with columns

from fluent_cards import AdaptiveCardBuilder

card = (AdaptiveCardBuilder.create()
    .with_version('1.5')
    .add_column_set(lambda cs: cs
        .add_column(lambda col: col
            .with_width('auto')
            .add_text_block(lambda tb: tb.with_text('Name:')))
        .add_column(lambda col: col
            .with_width('stretch')
            .add_text_block(lambda tb: tb.with_text('Jane Doe'))))
    .build())

Using choices (Input.ChoiceSet)

from fluent_cards import AdaptiveCardBuilder

card = (AdaptiveCardBuilder.create()
    .with_version('1.5')
    .add_input_choice_set(lambda cs: cs
        .with_id('priority')
        .with_label('Priority')
        .add_choice('High', 'high')
        .add_choice('Medium', 'medium')
        .add_choice('Low', 'low'))
    .build())

Validation

from fluent_cards import AdaptiveCardBuilder, validate

card = AdaptiveCardBuilder.create().build()  # no version set
errors = validate(card)

for error in errors:
    print(error)

API Reference

See the full API docs for all builder methods and enums.

Development

git clone https://github.com/rido-min/FluentCards.git
cd FluentCards/python
pip install -e ".[dev]"
pytest

License

MIT — see LICENSE for details.

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

fluent_cards-0.1.0b20.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

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

fluent_cards-0.1.0b20-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

Details for the file fluent_cards-0.1.0b20.tar.gz.

File metadata

  • Download URL: fluent_cards-0.1.0b20.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fluent_cards-0.1.0b20.tar.gz
Algorithm Hash digest
SHA256 e8827ea323ac5534049fbf1122f09413e266c2b8ecb251882d95a29cd0375208
MD5 bb948397cda2ba109fa8274ab71c75d4
BLAKE2b-256 6d6ec131a75dcb61205e2c7a9151a709d77f0f4292e10dc28020bd88109a80e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for fluent_cards-0.1.0b20.tar.gz:

Publisher: cd.yml on rido-min/FluentCards

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

File details

Details for the file fluent_cards-0.1.0b20-py3-none-any.whl.

File metadata

  • Download URL: fluent_cards-0.1.0b20-py3-none-any.whl
  • Upload date:
  • Size: 45.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fluent_cards-0.1.0b20-py3-none-any.whl
Algorithm Hash digest
SHA256 a1c2f4121ce534486ef350f0fba78fa1509af2caf6326ef1801e64acdff69da6
MD5 f02d17fb609e49436484b159caf6a675
BLAKE2b-256 53354f013c9f75426709d5a98de94e2e1af74fd7f24ee227caef0d0c0750ce93

See more details on using hashes here.

Provenance

The following attestation bundles were made for fluent_cards-0.1.0b20-py3-none-any.whl:

Publisher: cd.yml on rido-min/FluentCards

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