Registry / communication / slackweb

slackweb

JSON →
library1.0.5pypypi✓ verified 85d ago

Slackweb is a minimalistic Python library for sending messages to Slack via incoming webhooks. It provides a simple interface to construct and send webhook payloads, supporting basic text, attachments, and Block Kit components. The current version is 1.0.5, with releases occurring infrequently, primarily for bug fixes or minor enhancements.

pip install slackweb
INSTALL
IMPORT
SIG · SLACKWEB
S
slackweb
communicationpythonv1.0.5
Install
2.4s avg
Import
90ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.091s · 19.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.4s · import 0.090s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Slack
from slackweb import Slack
from slackweb import Client
The main class is `Slack`, not `Client`.

This quickstart demonstrates how to initialize the `Slack` client with your webhook URL and send various types of messages, including simple text, messages with custom sender information, and messages with attachments. Ensure `SLACK_WEBHOOK_URL` is set in your environment.

import os import slackweb # Get your Slack Incoming Webhook URL from environment variables # e.g., SLACK_WEBHOOK_URL='https://hooks.slack.com/services/T.../B.../...' WEBHOOK_URL = os.environ.get('SLACK_WEBHOOK_URL', 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX') if WEBHOOK_URL == 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX': print("WARNING: Please set the SLACK_WEBHOOK_URL environment variable to a valid Slack Incoming Webhook URL.") print("Skipping quickstart execution due to missing URL.") else: try: slack = slackweb.Slack(url=WEBHOOK_URL) # Send a simple text message slack.notify(text="Hello from slackweb! This is a test message.") print("Successfully sent a simple Slack message.") # Send a message to a specific channel with a username and emoji icon slack.notify( channel="#general", username="My Python Bot", icon_emoji=":robot_face:", text="Another message with custom sender info." ) print("Successfully sent a Slack message with custom sender info.") # Send a message with an attachment slack.notify( attachments=[ { "title": "Example Attachment", "text": "This is an attachment with some extra info.", "color": "#36a64f" } ] ) print("Successfully sent a Slack message with an attachment.") except Exception as e: print(f"An error occurred: {e}") print("Please ensure your SLACK_WEBHOOK_URL is correct and accessible.")
Debug
Known issues
gotchaThis library is *only* for Slack Incoming Webhooks. It does not support the full Slack Web API (e.g., chat.postMessage, users.list, RTM API) or Bot Token authentication. For full API access, use `slack_sdk` (the official Python Slack SDK).
fix
If you need broader Slack API functionality, switch to the `slack_sdk` library. `pip install slack_sdk`.
affects: All versions
deprecatedPrior to v1.0.3, the `Slack` object could potentially be instantiated without a `url` parameter and set later. As of v1.0.3, it is strongly recommended (and effectively required for immediate use) to pass the webhook URL directly to the constructor.
fix
Always initialize `slackweb.Slack` by passing the webhook URL: `slack = slackweb.Slack(url='YOUR_WEBHOOK_URL')`.
affects: <1.0.3 behavior, 1.0.3+
gotchaThe library might not immediately support the newest Slack Block Kit features or advanced authentication methods like OAuth token exchange. Always refer to the official Slack API documentation for the latest webhook payload structure.
fix
For complex Block Kit layouts, construct the `blocks` payload as a Python dictionary according to Slack's API docs and pass it directly to `slack.notify(blocks=...)`.
affects: All versions
Errors
Common errors & fixes
AttributeError: 'Slack' object has no attribute 'chat_postMessage'
Attempting to use full Slack Web API methods (like `chat_postMessage`) with the `slackweb` library, which is designed only for incoming webhooks.
fix
Use the `slack_sdk` library for full Slack Web API access. If you only need webhooks, use `slack.notify()`.
requests.exceptions.MissingSchema: Invalid URL 'YOUR_WEBHOOK_URL': No schema supplied. Perhaps you meant https://YOUR_WEBHOOK_URL?
The webhook URL provided to `slackweb.Slack` is missing the `http://` or `https://` scheme.
fix
Ensure your Slack webhook URL starts with `https://hooks.slack.com/...`.
TypeError: __init__() missing 1 required positional argument: 'url'
You tried to instantiate `slackweb.Slack()` without providing the `url` parameter in versions 1.0.3 and later.
fix
Pass the webhook URL directly to the constructor: `slack = slackweb.Slack(url='YOUR_WEBHOOK_URL')`.
Upgrade
Version history
1.0.5latest on PyPI · released Jun 23, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
26
OpenAI (training)
1
Resources
slackweb — pip install slackweb · libregistry