Unofficial Feishu/Lark Web SDK - WebSocket listener, message search, send, and drive operations
Project description
lark-bridge
Unofficial Feishu/Lark Web SDK using cookie-based authentication. Provides real-time message listening via WebSocket, message search/fetch, sending, and Drive operations.
⚠️ This library is reverse-engineered from Feishu's web client. It is not an official API and may break without notice.
Installation
pip install lark-bridge
Quick Start
import asyncio
from lark_bridge import LarkBridge
bridge = LarkBridge("your_cookie_string_here")
# For enterprise tenants with custom domain:
bridge = LarkBridge("your_cookie_string_here", domain="yourcompany.feishu.cn")
Listen to Messages
async def main():
async for msg in bridge.listen(watch_chats=["chat_id"]):
print(f"[{msg['chat_id']}] {msg['from_id']}: {msg['text']}")
asyncio.run(main())
Search History
# Simple: auto-paginate up to limit
result = await bridge.search_messages(
chat_id="7052636707732193282",
start_time=1716192000,
end_time=1716278400,
limit=50,
)
print(result["msg_ids"])
# Manual pagination:
page = await bridge.search_messages_page(chat_id="7052636707732193282")
while page["has_more"]:
page = await bridge.search_messages_page(
chat_id="7052636707732193282",
page_token=page["page_token"],
)
print(page["msg_ids"])
Fetch Messages
messages = await bridge.fetch_messages(["msg_id_1", "msg_id_2"])
for msg in messages:
print(msg["text"])
# Each message dict contains:
# msg_id, type, from_id, chat_id, parent_id, root_id, create_time, text
Send Message
await bridge.send_message(
chat_id="7052636707732193282",
text="Hello!",
reply_id="optional_msg_id",
at_user_ids=["user_id"],
)
Drive Operations
folder = await bridge.create_folder("My Folder", parent_token="root_token")
# folder = {"token": "...", "url": "https://domain/drive/folder/..."}
result = await bridge.upload_file(folder["token"], "report.txt", b"file content")
# result = {"file_token": "...", "node_token": "...", "url": "https://domain/file/..."}
Cookie Setup
- Open Feishu Web in your browser and log in
- Open DevTools (F12) → Application → Cookies
- Copy the full cookie string (all key=value pairs joined by
;) - Pass it to
LarkBridge("your_cookie_string")
Example cookie format:
cookie = "passport_web_did=YOUR_DID; session=YOUR_SESSION; _csrf_token=YOUR_CSRF_TOKEN"
bridge = LarkBridge(cookie)
Cookie typically stays valid as long as the WebSocket connection is maintained.
License
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 lark_bridge-0.2.3.tar.gz.
File metadata
- Download URL: lark_bridge-0.2.3.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72475fb6e53165a578fa824ea79067357f7ac5d2ca630e806f32fd12cfe6b422
|
|
| MD5 |
55224dc89fde74effc0d3dc2c69021f4
|
|
| BLAKE2b-256 |
e98fee3e7597769c7565c7c9043ad1c36c522fb438d2a47c48087c5b58cc1012
|
Provenance
The following attestation bundles were made for lark_bridge-0.2.3.tar.gz:
Publisher:
publish.yml on ryanwx/lark-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lark_bridge-0.2.3.tar.gz -
Subject digest:
72475fb6e53165a578fa824ea79067357f7ac5d2ca630e806f32fd12cfe6b422 - Sigstore transparency entry: 1663585151
- Sigstore integration time:
-
Permalink:
ryanwx/lark-bridge@6c672e97e361e0caf42263ee09173a33fa866cb3 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/ryanwx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6c672e97e361e0caf42263ee09173a33fa866cb3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lark_bridge-0.2.3-py3-none-any.whl.
File metadata
- Download URL: lark_bridge-0.2.3-py3-none-any.whl
- Upload date:
- Size: 26.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d95da3855daf2fb6a169a7ca979038f9878875fc8d75cee13002c621d8b1e8e0
|
|
| MD5 |
0ca381886567f0640051333d8db87dcf
|
|
| BLAKE2b-256 |
3f03d3041645aef0877967221ccb1027743616d2aca862c273ca95557fc65f48
|
Provenance
The following attestation bundles were made for lark_bridge-0.2.3-py3-none-any.whl:
Publisher:
publish.yml on ryanwx/lark-bridge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lark_bridge-0.2.3-py3-none-any.whl -
Subject digest:
d95da3855daf2fb6a169a7ca979038f9878875fc8d75cee13002c621d8b1e8e0 - Sigstore transparency entry: 1663586079
- Sigstore integration time:
-
Permalink:
ryanwx/lark-bridge@6c672e97e361e0caf42263ee09173a33fa866cb3 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/ryanwx
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6c672e97e361e0caf42263ee09173a33fa866cb3 -
Trigger Event:
push
-
Statement type: