slackblocks


Nameslackblocks JSON
Version 1.0.8 PyPI version JSON
download
home_pagehttps://github.com/nicklambourne/slackblocks
SummaryPython wrapper for the Slack Blocks API
upload_time2024-04-29 06:33:30
maintainerNicholas Lambourne
docs_urlNone
authorNicholas Lambourne
requires_python>=3.8.0
licenseMIT
keywords slackblocks slack messaging message generation slack blocks blocks
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # slackblocks <img src="https://github.com/nicklambourne/slackblocks/raw/master/docs_src/img/sb.png" align="right" width="250px"/>

![Licence: MIT](https://img.shields.io/badge/License-MIT-green.svg)
![Licence: BSD-3-Clause](https://img.shields.io/badge/License-BSD_3_Clause-green.svg)
![Python Versions](https://img.shields.io/pypi/pyversions/slackblocks)
[![PyPI](https://img.shields.io/pypi/v/slackblocks?color=yellow&label=PyPI&logo=python&logoColor=white)](https://pypi.org/project/slackblocks/#history)
[![Downloads](https://static.pepy.tech/badge/slackblocks)](https://pepy.tech/project/slackblocks)
[![Build Status](https://github.com/nicklambourne/slackblocks/actions/workflows/unit-tests.yml/badge.svg?branch=master)](https://github.com/nicklambourne/slackblocks/actions)
[![Docs](https://img.shields.io/badge/Docs-8A2BE2.svg)](https://nicklambourne.github.io/slackblocks)

## What is it?
`slackblocks` is a Python API for building messages in the fancy Slack [Block Kit API](https://api.slack.com/block-kit)

## Documentation
Full documentation is provided [here](https://nicklambourne.github.io/slackblocks/latest/).

## Requirements
`slackblocks` requires Python >= 3.8.

As of version 0.1.0 it has no dependencies outside the Python standard library.

## Installation
```bash
pip install slackblocks
```

## Basic Usage
```python
from slackblocks import Message, SectionBlock


block = SectionBlock("Hello, world!")
message = Message(channel="#general", blocks=block)
message.json()

```

Will produce the following JSON string:
```json
{
    "channel": "#general",
    "mrkdwn": true,
    "blocks": [
        {
            "type": "section",
            "block_id": "992ceb6b-9ad4-496b-b8e6-1bd8a632e8b3",
            "text": {
                "type": "mrkdwn",
                "text": "Hello, world!"
            }
        }
    ]
}
```
Which can be sent as payload to the Slack message API HTTP endpoints.

Of more practical uses is the ability to unpack the objects directly into 
the Python Slack Client in order to send messages:
```python
from os import environ
from slack import WebClient
from slackblocks import Message, SectionBlock


client = WebClient(token=environ["SLACK_API_TOKEN"])
block = SectionBlock("Hello, world!")
message = Message(channel="#general", blocks=block)

response = client.chat_postMessage(**message)
```

Note the `**` operator in front of the `message` object.

## Can I use this in my project?
Yes, please do! The code is all open source and dual BSD-3.0 and MIT licensed
    (use what suits you best).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nicklambourne/slackblocks",
    "name": "slackblocks",
    "maintainer": "Nicholas Lambourne",
    "docs_url": null,
    "requires_python": ">=3.8.0",
    "maintainer_email": "dev@ndl.im",
    "keywords": "slackblocks, slack, messaging, message generation, slack blocks, blocks",
    "author": "Nicholas Lambourne",
    "author_email": "dev@ndl.im",
    "download_url": "https://files.pythonhosted.org/packages/5f/e8/207b465a6dfcd7cdbbd81bf42e88457e9f23ed9fbaf67343c1e017fc82bf/slackblocks-1.0.8.tar.gz",
    "platform": null,
    "description": "# slackblocks <img src=\"https://github.com/nicklambourne/slackblocks/raw/master/docs_src/img/sb.png\" align=\"right\" width=\"250px\"/>\n\n![Licence: MIT](https://img.shields.io/badge/License-MIT-green.svg)\n![Licence: BSD-3-Clause](https://img.shields.io/badge/License-BSD_3_Clause-green.svg)\n![Python Versions](https://img.shields.io/pypi/pyversions/slackblocks)\n[![PyPI](https://img.shields.io/pypi/v/slackblocks?color=yellow&label=PyPI&logo=python&logoColor=white)](https://pypi.org/project/slackblocks/#history)\n[![Downloads](https://static.pepy.tech/badge/slackblocks)](https://pepy.tech/project/slackblocks)\n[![Build Status](https://github.com/nicklambourne/slackblocks/actions/workflows/unit-tests.yml/badge.svg?branch=master)](https://github.com/nicklambourne/slackblocks/actions)\n[![Docs](https://img.shields.io/badge/Docs-8A2BE2.svg)](https://nicklambourne.github.io/slackblocks)\n\n## What is it?\n`slackblocks` is a Python API for building messages in the fancy Slack [Block Kit API](https://api.slack.com/block-kit)\n\n## Documentation\nFull documentation is provided [here](https://nicklambourne.github.io/slackblocks/latest/).\n\n## Requirements\n`slackblocks` requires Python >= 3.8.\n\nAs of version 0.1.0 it has no dependencies outside the Python standard library.\n\n## Installation\n```bash\npip install slackblocks\n```\n\n## Basic Usage\n```python\nfrom slackblocks import Message, SectionBlock\n\n\nblock = SectionBlock(\"Hello, world!\")\nmessage = Message(channel=\"#general\", blocks=block)\nmessage.json()\n\n```\n\nWill produce the following JSON string:\n```json\n{\n    \"channel\": \"#general\",\n    \"mrkdwn\": true,\n    \"blocks\": [\n        {\n            \"type\": \"section\",\n            \"block_id\": \"992ceb6b-9ad4-496b-b8e6-1bd8a632e8b3\",\n            \"text\": {\n                \"type\": \"mrkdwn\",\n                \"text\": \"Hello, world!\"\n            }\n        }\n    ]\n}\n```\nWhich can be sent as payload to the Slack message API HTTP endpoints.\n\nOf more practical uses is the ability to unpack the objects directly into \nthe Python Slack Client in order to send messages:\n```python\nfrom os import environ\nfrom slack import WebClient\nfrom slackblocks import Message, SectionBlock\n\n\nclient = WebClient(token=environ[\"SLACK_API_TOKEN\"])\nblock = SectionBlock(\"Hello, world!\")\nmessage = Message(channel=\"#general\", blocks=block)\n\nresponse = client.chat_postMessage(**message)\n```\n\nNote the `**` operator in front of the `message` object.\n\n## Can I use this in my project?\nYes, please do! The code is all open source and dual BSD-3.0 and MIT licensed\n    (use what suits you best).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python wrapper for the Slack Blocks API",
    "version": "1.0.8",
    "project_urls": {
        "Homepage": "https://github.com/nicklambourne/slackblocks",
        "Repository": "https://github.com/nicklambourne/slackblocks"
    },
    "split_keywords": [
        "slackblocks",
        " slack",
        " messaging",
        " message generation",
        " slack blocks",
        " blocks"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f67f5a913dcec019faa4d3ead4a7879891b183fe84f3f5086059afd5bd0ce0d",
                "md5": "da70ceefc19dfc37e93e7972d90351a1",
                "sha256": "5ba3006545cdc8c3525213c488fb625ec0a302887cc55eb0be410b43d3bf9344"
            },
            "downloads": -1,
            "filename": "slackblocks-1.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "da70ceefc19dfc37e93e7972d90351a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0",
            "size": 36202,
            "upload_time": "2024-04-29T06:33:28",
            "upload_time_iso_8601": "2024-04-29T06:33:28.623629Z",
            "url": "https://files.pythonhosted.org/packages/5f/67/f5a913dcec019faa4d3ead4a7879891b183fe84f3f5086059afd5bd0ce0d/slackblocks-1.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5fe8207b465a6dfcd7cdbbd81bf42e88457e9f23ed9fbaf67343c1e017fc82bf",
                "md5": "8a0a7c9e2ff2243b27368e3a21647b2a",
                "sha256": "acd956cca09bee4f7de0f786be90ec790d5e16b6880e6fdfa754076a829af2f5"
            },
            "downloads": -1,
            "filename": "slackblocks-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "8a0a7c9e2ff2243b27368e3a21647b2a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0",
            "size": 30902,
            "upload_time": "2024-04-29T06:33:30",
            "upload_time_iso_8601": "2024-04-29T06:33:30.427954Z",
            "url": "https://files.pythonhosted.org/packages/5f/e8/207b465a6dfcd7cdbbd81bf42e88457e9f23ed9fbaf67343c1e017fc82bf/slackblocks-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-29 06:33:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nicklambourne",
    "github_project": "slackblocks",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "slackblocks"
}
        
Elapsed time: 0.28314s