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.1

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: lark_oapi-1.6.1.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.1.tar.gz
Algorithm Hash digest
SHA256 34d0594464e37c5a5ffbb398a567f8f3c608d6f49496b828a897233f094cc067
MD5 a75fc2edc41204bf0be7d81e125182d8
BLAKE2b-256 93e289665d999a87ee1947bfd9109ff17c5259020293958d85ac0eef1f2e14f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lark_oapi-1.6.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 faa91fe7de809dbdb5eb8d81604c96eaba4da9e36d1fdbbd10a47bff7e010bf3
MD5 8a69f0d3335eff123348a37902fcaf0b
BLAKE2b-256 0a8e53451b915a806506b4838c81ff76dfb637e2f6615a1c9016fe9ebd6af5b5

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