skillfed

dingtalk-stream

A Python library for sending messages to DingTalk chatbot

dingtalk-stream v0.24.3 794.0K downloads/30d#5,039 on PyPI173
Permissive license MIT Active released

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-stream

uv

uv add dingtalk-stream

poetry

poetry add dingtalk-stream

Installing 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

Development Status :: 3 - AlphaIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

dingtalk chatbot sdkdingtalk stream modedingtalk event handlerdingtalk webhook alternativedingtalk message callbackdingtalk bot python
dingtalk-integrationchatbot-frameworkwebsocket-client

More WWW/HTTP packages