slackblocks
Python wrapper for the Slack Blocks API
What it is and what it does
slackblocks is a typed Python wrapper around Slack's Block Kit API that lets you construct rich Slack messages, modals, and home tabs using concise Python objects instead of verbose JSON. It enforces validation at construction time—character limits, required fields, mutually-exclusive options, element-type restrictions—so errors surface before the API call, not after. The library ships with full type hints and zero runtime dependencies, making it lightweight and IDE-friendly.
It integrates directly with official Slack SDKs via unpacking: `client.chat_postMessage(**message)` works without boilerplate. The package supports all current block types (including Alert, Card, Carousel, Container, Data Table, Plan, Task Card), elements (buttons, select menus, date/time pickers, checkboxes, radio groups, workflow buttons), composition objects, rich text, modals, views, and round-trip parsing of incoming Slack JSON back into objects.
Use it for:
- Build structured build-status notifications with fields, buttons, and dividers without writing JSON templates.
- Generate approval-request modals with validation and interactive elements for workflow automation.
- Construct data-driven Slack messages (e.g., incident alerts, report summaries) with type-safe field assembly.
- Parse incoming Slack interaction payloads back into slackblocks objects for programmatic inspection and response.
- Create reusable message templates as Python functions, leveraging type hints for IDE autocomplete and refactoring.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Builds Slack Block Kit messages programmatically in Python with type validation, eliminating hand-written JSON and reducing API errors before they reach Slack.
Yes. Zero dependencies, active maintenance, permissive dual licensing, and no known vulnerabilities make it a safe choice. Install if you send structured Slack messages from Python and want to avoid JSON boilerplate and validation errors—the typed API and up-front validation pay off immediately. Requires Python 3.10 or newer.
Install
slackblocks on PyPI
pip
pip install slackblocksuv
uv add slackblockspoetry
poetry add slackblocksInstalling slackblocks
Before you install
Installs with zero runtime dependencies as a pure-Python wheel. Active maintenance with a release on 2026-08-14 and 75 repository stars.
License in practice
Dual-licensed under MIT and BSD-3-Clause, permitting use in both permissive and copyleft projects; choose whichever fits your licensing requirements.
Quickstart
pip install slackblocks
from slackblocks import Message, HeaderBlock, SectionBlock, Button, ActionsBlock
message = Message(
channel="#general",
text="Build passed",
blocks=[
HeaderBlock("Build #482 passed :white_check_mark:"),
SectionBlock(fields=["*Branch*\n`main`", "*Author*\n@nick"]),
ActionsBlock(elements=[Button(text="View", url="https://example.com")])
]
)
Requires Python 3.10 or newer; Python 3.8/3.9 users must pin to the 1.x line.
Verify before relying
- Whether the package's round-trip parsing (Block.from_dict) handles all current Slack API responses without data loss.
- Performance characteristics when building large messages with hundreds of blocks or elements.
- Compatibility with Slack API changes after the 2026-08-14 release date.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 0 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 78,520/month — #14,436 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: slackblocks-2.1.0-py3-none-any.whl
Keywords: blocks, message generation, messaging, slack, slack blocks, slackblocks
Tags
More Chat packages
Provides Python bindings for Slack's Web API,…
permissive · top 1,000 on PyPI
python-telegram-botProvides a pure Python asynchronous interface…
copyleft · top 1,000 on PyPI
slackclientProvides Python interfaces to Slack's Web API…
permissive · top 5,000 on PyPI
aiogramaiogram is an asynchronous Python framework for…
permissive · top 5,000 on PyPI
TelethonTelethon is an asyncio-based Python library…
permissive · top 5,000 on PyPI
mleapSerializes and deserializes machine learning…
permissive · top 5,000 on PyPI
pyblock-builderPyBlock Builder provides Python classes and…
permissive · top 15,000 on PyPI
blockkitBlockKit builds Slack UI blocks…
permissive · top 15,000 on PyPI
prefect-slackProvides prebuilt Prefect tasks and blocks to…
permissive · top 15,000 on PyPI
slackwebSends messages to Slack channels via incoming…
permissive · top 15,000 on PyPI
markdown-to-mrkdwnConverts standard Markdown to Slack's mrkdwn…
permissive · top 5,000 on PyPI
md2SlackConverts Markdown syntax into Slack-compatible…
permissive · top 15,000 on PyPI
mdformat-blackA plugin for mdformat that automatically…
permissive · top 15,000 on PyPI
slack-boltBolt for Python is a framework for building…
permissive · top 5,000 on PyPI