Skip to main content

Lark OpenAPI SDK for Python

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

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.

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

lark_oapi-1.6.5.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lark_oapi-1.6.5-py3-none-any.whl (7.1 MB view details)

Uploaded Python 3

File details

Details for the file lark_oapi-1.6.5.tar.gz.

File metadata

  • Download URL: lark_oapi-1.6.5.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

Hashes for lark_oapi-1.6.5.tar.gz
Algorithm Hash digest
SHA256 abf1fd348bd527502c70f2fe771c6fd37c2b8bbed188c9313596063864d43f59
MD5 82ed05eb1053bf4b2ac311bd0f1ea55e
BLAKE2b-256 a16acfaa24851e05000a3bede7a3d30b834116d684d56738d08980da621e9c1a

See more details on using hashes here.

File details

Details for the file lark_oapi-1.6.5-py3-none-any.whl.

File metadata

  • Download URL: lark_oapi-1.6.5-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

Hashes for lark_oapi-1.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a56fa548aebdae9c36ef0114fbbc6e5d004eb2e15398e11cf88a5737f0cf8641
MD5 d44bb95171ebf3bc9fa51c91041767cd
BLAKE2b-256 4028a425593c6de71b80ad642ed8e624468a2848ea0e4ad7cb32a8380941fd7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page