Skip to main content

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

飞书开放接口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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lark_oapi-1.6.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d98b89cb476be433d654e92252bb33bfbaeccfe87fda14ddec4b384096162d6f
MD5 83c2ffa3798facf0b670e98ba4f58cce
BLAKE2b-256 d148cc1ffab88050ba015b7248038d35974a012a904ab240a85189d136c16552

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lark_oapi-1.6.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 65d1ddac1ecaa728d1ffbc9c6fdffb896d76654cf8c7a2922ca4bc4114e74f7a
MD5 71fa8614e1b8b6a68940877b685766c7
BLAKE2b-256 d4fe022c018e9321ec60134bed015b3e34eaf85d06485fe422b71f5a82597934

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