dingtalk-stream
A Python library for sending messages to DingTalk chatbot
What it is and what it does
dingtalk-stream is a Python SDK that implements DingTalk's Stream Mode protocol for building chatbots and event handlers. Instead of polling or managing webhooks, it opens a persistent WebSocket connection to DingTalk's servers and receives events (messages, callbacks, card interactions) asynchronously. You define handler classes that process incoming events and send replies back through the same connection.
The SDK wraps the async complexity: you write a handler class with a process() method, register it with a DingTalkStreamClient, and call start_forever() to begin listening. It handles credential management, WebSocket lifecycle, and message acknowledgment. The library depends on aiohttp, requests, and websockets for its HTTP and WebSocket transport layers.
Use it for:
- Build a DingTalk chatbot that responds to user messages in real time without setting up external webhooks or polling.
- Handle card callback events (button clicks, form submissions) from DingTalk cards sent by your application.
- Integrate DingTalk event notifications into an existing asyncio application using client.start() instead of start_forever().
- Process multiple event types (messages, callbacks, approvals) by registering different handler classes for each topic.
- Deploy a stateless bot that maintains a single persistent connection to DingTalk rather than multiple HTTP endpoints.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Python SDK for building DingTalk chatbots and event handlers using Stream Mode, which connects to DingTalk's messaging and callback APIs via WebSocket.
Yes, if you are building a DingTalk chatbot or event handler in Python. The SDK is actively maintained, has low install friction, uses a permissive MIT license, and is classified as Alpha development status. No known vulnerabilities. The main gotcha is that you must obtain DingTalk credentials and understand that Stream Mode requires a persistent WebSocket connection rather than stateless HTTP webhooks.
Install
dingtalk-stream on PyPI
pip
pip install dingtalk-streamuv
uv add dingtalk-streampoetry
poetry add dingtalk-streamInstalling dingtalk-stream
Before you install
Low install friction with a pure-Python wheel. Actively maintained as of 2026-07-30 with 173 repository stars. Depends on aiohttp, requests, and websockets for async HTTP and WebSocket communication.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install dingtalk-stream
import dingtalk_stream
credential = dingtalk_stream.Credential(client_id, client_secret)
client = dingtalk_stream.DingTalkStreamClient(credential)
client.register_callback_handler(dingtalk_stream.chatbot.ChatbotMessage.TOPIC, handler)
client.start_forever()
Requires DingTalk app credentials (client_id and client_secret) from https://open-dev.digntalk.com; Stream Mode connection is WebSocket-based and requires network access to DingTalk servers.
Verify before relying
- Whether Python 3.6 and 3.7 support (listed in classifiers) is actively tested or maintained given the active status.
- Performance characteristics under high message volume or concurrent callback handlers.
- Whether the package handles automatic reconnection and backoff after network failures, or if manual restart is always required.
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — aiohttp, requests, websockets |
| Maintenance | actively maintained — 294 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 793,984/month — #5,039 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: dingtalk_stream-0.24.3-py3-none-any.whl
Tags
More WWW/HTTP packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
h11h11 is a pure-Python HTTP/1.1 protocol…
permissive · top 100 on PyPI
httpxHTTPX is a fully featured HTTP client library…
permissive · top 100 on PyPI
httpcoreA minimal low-level HTTP client library that…
permissive · top 100 on PyPI
aiohttpaiohttp is an async HTTP client and server…
permissive · top 100 on PyPI
alibabacloud-dingtalkPython SDK for integrating with Alibaba Cloud's…
permissive · top 15,000 on PyPI
line-bot-sdkSDK for building LINE bots that handles webhook…
permissive · top 5,000 on PyPI
alibabacloud-gateway-dingtalkProvides a gateway client for integrating with…
permissive · top 15,000 on PyPI
apache-airflow-providers-dingdingIntegrates Apache Airflow with DingTalk,…
permissive · top 15,000 on PyPI
pytest-messengerA pytest plugin that sends test results to…
permissive · top 5,000 on PyPI
jeedomdaemonProvides a base class and framework for…
permissive · top 15,000 on PyPI
slackwebSends messages to Slack channels via incoming…
permissive · top 15,000 on PyPI
fbmessengerA Python library for sending and receiving…
permissive · top 15,000 on PyPI
wecom-aibot-python-sdkA Python SDK for WeChat Work (企业微信) AI bot that…
permissive · top 15,000 on PyPI
stream-chatPython SDK for server-side integration with…
unclear · top 15,000 on PyPI