Unofficial Python SDK for the iLink-compatible Weixin bot protocol.
Project description
wechat-link
Connect WeChat to your app, agent, or workflow with a small amount of Python.
Scan to log in, then receive messages, reply, and send media without building a full bot platform first.
wechat-link is an unofficial Python SDK for iLink-compatible Weixin Bot integration. It keeps the path intentionally simple: get connected fast, then extend the integration your own way.
What it currently provides
- QR login primitives:
get_bot_qrcode()/get_qrcode_status() - Long polling:
get_updates() - Typed inbound media parsing / download:
WeixinMessage.items()/Client.download_message_item() - Text messaging:
send_text() - Typing support:
get_config()/send_typing() - Media workflow:
get_upload_url()upload_image()/send_image()upload_file()/send_file()upload_video()/send_video()upload_voice()/send_voice()
- OpenClaw-compatible adapter:
OpenClawWeixinAdapterwith inbound archive extraction and outbound image/video/voice/file routing - Optional FastAPI relay layer
Installation
pip install wechat-link
Relay extras:
pip install "wechat-link[relay]"
Getting started order
If this is your first time using the SDK, follow this order:
- Run QR login first and obtain
bot_token - Initialize
Client(bot_token=...) - Start polling and sending messages
The SDK returns bot_token, baseurl, ilink_bot_id, and ilink_user_id after QR confirmation. The value you need for Client(...) is bot_token.
For QR display, qrcode_img_content is currently a URL. If that URL points to a QR page instead of a raw image, the SDK generates a real QR locally. Client.save_qrcode_image(...) saves it to a local file, while Client.render_qrcode_terminal(...) / Client.print_qrcode_terminal(...) can render it directly in the terminal.
Minimal usage example
from wechat_link import Client, FileCursorStore
client = Client(bot_token="your-bot-token")
store = FileCursorStore(".state/get_updates_buf.json")
cursor = store.load() or ""
updates = client.get_updates(cursor=cursor)
if updates.next_cursor:
store.save(updates.next_cursor)
for message in updates.messages:
print("from_user_id:", message.from_user_id)
print("context_token:", message.context_token)
print("text:", message.text())
client.close()
Quick example
If you want the clearest learning path, use these repository examples in order:
python examples/login_session.pypython examples/receive_once.pypython examples/reply_once.pypython examples/send_text_in_session.pypython examples/echo_bot.py
The important boundary is that replying or sending within an existing conversation requires the upstream context_token.
Core reply example:
client.send_text(
to_user_id=message.from_user_id,
text=f"received: {message.text()}",
context_token=message.context_token,
)
Advanced repository examples:
python examples/receive_media_once.pydownloads inbound image / video / voice / file messagespython examples/send_media.pysends image / file / video / voice messagespython examples/openclaw_adapter_once.pyprints the OpenClaw-style context, including archive extraction metadata
Full three-step example
If you want the full onboarding flow in one runnable file, use:
python examples/quickstart_three_steps.py
The repository version of that example handles QR login, session persistence, and the echo loop end to end. When run from the repository, it prefers local src/wechat_link first and writes runtime files into the repository .state/ directory.
Project links
- Repository: https://github.com/syusama/wechat-link
- Issues: https://github.com/syusama/wechat-link/issues
- Chinese README: https://github.com/syusama/wechat-link/blob/main/README.md
- English README: https://github.com/syusama/wechat-link/blob/main/README.en.md
- Japanese README: https://github.com/syusama/wechat-link/blob/main/README.ja.md
Notes
- This is an unofficial project.
- It should not be described as a Tencent official SDK or official platform replacement.
- The PyPI page keeps the package overview concise; the full documentation and examples live in the GitHub repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wechat_link-0.3.0.tar.gz.
File metadata
- Download URL: wechat_link-0.3.0.tar.gz
- Upload date:
- Size: 53.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2f5bb3e56d1f423374e80ccd8436609822e52ee08a9b5f5837b13939f825176
|
|
| MD5 |
2d9e6728865f3e36a06c3287cb971457
|
|
| BLAKE2b-256 |
6c30523335e80424af90577533fc33c8639b6908dbbde801fe03d0683ee0abc7
|
Provenance
The following attestation bundles were made for wechat_link-0.3.0.tar.gz:
Publisher:
publish.yml on syusama/wechat-link
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wechat_link-0.3.0.tar.gz -
Subject digest:
c2f5bb3e56d1f423374e80ccd8436609822e52ee08a9b5f5837b13939f825176 - Sigstore transparency entry: 1197642804
- Sigstore integration time:
-
Permalink:
syusama/wechat-link@4ae7bea71054a5fc5ee3dee15fc082826551cef1 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/syusama
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4ae7bea71054a5fc5ee3dee15fc082826551cef1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file wechat_link-0.3.0-py3-none-any.whl.
File metadata
- Download URL: wechat_link-0.3.0-py3-none-any.whl
- Upload date:
- Size: 21.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cf565fe7fa17cfdef53daa830f4c26294fe244819a491aab423424f8f62ea4b
|
|
| MD5 |
37285016d42f57911468721cb7b05135
|
|
| BLAKE2b-256 |
17f2318f467805bf14b9c52cdf0356db8075d260c68c16b8f45539defc033c68
|
Provenance
The following attestation bundles were made for wechat_link-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on syusama/wechat-link
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wechat_link-0.3.0-py3-none-any.whl -
Subject digest:
3cf565fe7fa17cfdef53daa830f4c26294fe244819a491aab423424f8f62ea4b - Sigstore transparency entry: 1197642886
- Sigstore integration time:
-
Permalink:
syusama/wechat-link@4ae7bea71054a5fc5ee3dee15fc082826551cef1 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/syusama
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4ae7bea71054a5fc5ee3dee15fc082826551cef1 -
Trigger Event:
push
-
Statement type: