LarkToolkit
init
- app_id (Optional[str]): The Lark application ID. If not provided, uses LARK_APP_ID environment variable.
- app_secret (Optional[str]): The Lark application secret. If not provided, uses LARK_APP_SECRET environment variable.
- use_feishu (bool): Set to True to use Feishu (China) API endpoints instead of Lark (international). (default: :obj:
False) - timeout (Optional[float]): Request timeout in seconds.
_get_tenant_http_headers
_convert_timestamp
- ts: Timestamp value (can be string or int, in milliseconds).
_process_message_items
- items: List of message items from API response.
lark_list_chats
- sort_type (str): Sort order for chats. Options: - “ByCreateTimeAsc” (default) - “ByActiveTimeDesc”
- page_size (int): Number of chats to return per page (max 100). (default: :obj:
20) - page_token (Optional[str]): Token for pagination. Use the page_token from previous response to get next page.
- chats: List of chat objects with chat_id and name
- has_more: Whether there are more chats to fetch
- page_token: Token to fetch the next page
lark_get_chat_messages
- container_id (str): The container ID to retrieve messages from.
- container_id_type (str): The container type. Options: - “chat”: Chat (p2p or group) - “thread”: Thread
- start_time (Optional[str]): Start time filter (Unix timestamp in seconds, e.g., “1609459200”). Messages created after this time. Not supported for “thread” container type.
- end_time (Optional[str]): End time filter (Unix timestamp in seconds). Messages created before this time. Not supported for “thread” container type.
- sort_type (str): Sort order for messages. Options: - “ByCreateTimeAsc”: Oldest first (default) - “ByCreateTimeDesc”: Newest first
- page_size (int): Number of messages to return per page (max 50). (default: :obj:
20) - page_token (Optional[str]): Token for pagination. Use the page_token from previous response to get next page.
- messages: List of processed message objects with fields:
- message_id: Message identifier
- msg_type: Message type (text, image, file, etc.)
- text: Extracted message text content
- time: Human-readable timestamp (UTC)
- sender_id: Sender’s user ID
- sender_type: Type of sender
- has_more: Whether there are more messages to fetch
- page_token: Token to fetch the next page
lark_get_message_resource
- message_id (str): The message ID containing the resource.
- file_key (str): The resource file key from message content.
- resource_type (str): Resource type, either “image” or “file”.
- content_type: Response Content-Type header value
- path: File path where content was saved
- size: Content size in bytes
lark_get_message_resource_key
- message_id (str): The message ID to fetch.
- key: The resource key from message content