Lark OpenAPI SDK for Python
Reason this release was yanked:
Webhook signature compatibility regression: plaintext callbacks may fail when X-Lark-Signature is present. Use 1.6.4.
Project description
Feishu OpenPlatform Server SDK for Python
The Feishu Open Platform provides server-side APIs for messaging, contacts, approval, sheets, Base, and many other product capabilities. This SDK wraps the repeated platform work around API calls, including token management, request signing, encryption/decryption, event dispatching, and typed request/response models.
Documentation
- Preparations before development
- Calling server-side APIs
- Handle events
- Handle card callbacks
- SDK FAQs
Installation
pip install lark-oapi
Python 3.8 or later is required.
Basic Usage
import lark_oapi as lark
from lark_oapi.api.im.v1 import *
client = lark.Client.builder() \
.app_id("cli_xxx") \
.app_secret("your_app_secret") \
.build()
request = CreateMessageRequest.builder() \
.receive_id_type("chat_id") \
.request_body(CreateMessageRequestBody.builder()
.receive_id("oc_xxx")
.msg_type("text")
.content("{\"text\":\"hello world\"}")
.build()) \
.build()
response = client.im.v1.message.create(request)
Channel Module
lark_oapi.channel is a high-level module built on top of the OpenAPI client
and event transport. It bundles event listening, message normalization, safety
policy, outbound sending, media upload/download, card interactions, and
streaming replies into a single FeishuChannel entry point.
Use Channel when you are building a conversational bot that needs normalized message events, replies, media handling, card callbacks, mention policy, or WebSocket/webhook transport management.
import asyncio
import os
from lark_oapi.channel import FeishuChannel
channel = FeishuChannel(
app_id=os.environ["LARK_APP_ID"],
app_secret=os.environ["LARK_APP_SECRET"],
)
async def on_message(msg):
await channel.send(
msg.chat_id,
{"text": f"echo: {msg.content_text}"},
)
channel.on("message", on_message)
asyncio.run(channel.connect())
Full Channel documentation:
Examples
More composite API examples and business scenario samples are available in oapi-sdk-python-demo.
- Send file message
- Send image message
- List users under a department
- Create a Base app with tables
- Robot quick start
License
MIT
Contact Us
Click Server SDK in the upper right corner of the documentation page and submit feedback.
Project details
Release history Release notifications | RSS feed
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_oapi-1.6.3.tar.gz.
File metadata
- Download URL: lark_oapi-1.6.3.tar.gz
- Upload date:
- Size: 2.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0489747835eed32820af860a276e549943d29653c84c74af3ec426c7639c42a8
|
|
| MD5 |
5e660d923084232b5410d7c5e91d26c0
|
|
| BLAKE2b-256 |
acfc5bad0661d89d2ee56eff95c8d8202973dcdabd0df85fcca54dea8e983ea6
|
File details
Details for the file lark_oapi-1.6.3-py3-none-any.whl.
File metadata
- Download URL: lark_oapi-1.6.3-py3-none-any.whl
- Upload date:
- Size: 7.1 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3d8d7222cd24c6da23b6c00e420d530f5c028a8d8a3ce845539f1bb6c304448
|
|
| MD5 |
f72ab9a17ca732ff602879e87f8cc175
|
|
| BLAKE2b-256 |
909d85b3397e332c8001abb72700b5b6a97ac4c2c1244b731d568a5432ab9b2f
|