Skip to main content

Lark OpenAPI SDK for Python

Project description

飞书开放接口SDK/Feishu OpenPlatform Server SDK

旨在让开发者便捷的调用飞书开放API、处理订阅的事件、处理服务端推送的卡片行为等。

Feishu Open Platform offers a series of server-side atomic APIs to achieve diverse functionalities. However, actual coding requires additional work, such as obtaining and maintaining access tokens, encrypting and decrypting data, and verifying request signatures. Furthermore, the lack of semantic descriptions for function calls and type system support can increase coding burdens.

To address these issues, Feishu Open Platform has developed the Open Interface SDK, which incorporates all lengthy logic processes, provides a comprehensive type system, and offers a semantic programming interface to enhance the coding experience.

介绍文档 Introduction Documents

扩展示例

我们还基于 SDK 封装了常用的 API 组合调用及业务场景示例,如:

更多示例可参考:https://github.com/larksuite/oapi-sdk-python-demo

Channel module

lark_oapi.channel is a higher-level capability layer on top of the core OpenAPI client. It wraps event subscription, message normalization, outbound sending, streaming card updates, deduplication, retries, and SSRF-guarded media uploads behind a single FeishuChannel class — so a working bot is only a handful of lines.

Install

pip install lark-oapi

Quickstart — echo bot

import asyncio
from lark_oapi.channel import FeishuChannel

channel = FeishuChannel(app_id="cli_xxx", app_secret="***")

@channel.on("message")
async def on_message(msg):
    await channel.send(
        msg.conversation.chat_id,
        {"text": f"echo: {msg.content_text}"},
    )

asyncio.run(channel.connect())

channel.connect() opens a long-lived WebSocket to Feishu, dispatches inbound events through registered on(...) handlers, and keeps the connection alive across reconnects. channel.send(...) accepts plain dicts ({"text": ...}, {"markdown": ...}, {"card": ...}) or strongly-typed Outbound* payloads from lark_oapi.channel.

See the Channel quickstart, Channel reference, and Channel echo bot sample for runnable usage and API details. The public surface is exported from lark_oapi.channel.

Requirements

Python >= 3.8

License

MIT

加入交流互助群

单击或扫码加入讨论群

讨论群

Project details


Release history Release notifications | RSS feed

This version

1.6.0

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.0.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.0-py3-none-any.whl (7.1 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lark_oapi-1.6.0.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.0.tar.gz
Algorithm Hash digest
SHA256 da8ff124635a62819618ac409c0e1275d47a74b606de8b03173aec3b122a7393
MD5 211056e903b2625b7fddb4442fcd4099
BLAKE2b-256 85183770b74ce7e91af4b45a7b5c2c86084851e8997006b696aaddcd91b7977c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lark_oapi-1.6.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 edb5a905725a7846e949ee3a00b96bb2fdcd882e1bfc6ba3d568719f90481e3f
MD5 ec634c4ecaa64b95483f5f5dadbac4b1
BLAKE2b-256 be365e60581a7c671e964ba5ccbc635a56e32cb36cf89074f7170450017a17f2

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