Feishu SDK Rust
Notice: This is a community-maintained crate and is not an official Feishu/Lark SDK.
Rust SDK for Feishu/Lark Open Platform API. Provides a complete, type-safe interface to interact with Feishu APIs.
Features
- Complete API Coverage: 1448+ operations from Feishu Open Platform
- Token Management: Automatic app_access_token and tenant_access_token handling
- Event Processing: Event subscription and card callback handling
- WebSocket Support: Long connection for real-time messaging
- HTTP Server: Built-in Salvo server for webhook handling
- Type Safety: Generated operation constants and typed APIs
- Async/Await: Full async support with tokio runtime
- Pluggable Components: Customizable cache, logger, serializer, and HTTP client
- Code Generation: Operation wrappers + typed model stubs from endpoint catalog
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
Optional Features
[]
= { = "0.1", = ["server", "websocket"] }
server: Enable HTTP server for event handling (Salvo)websocket: Enable WebSocket client for long connections
Quick Start
Basic Usage
use ;
use Client;
async
Send Message
use Config;
use Client;
async
Event Handling Server
use ;
use ;
use FeishuServer;
async
WebSocket Client
use noop_logger;
use ;
use Duration;
async
Configuration
Basic Configuration
use ;
use Duration;
let config = builder
.base_url // or LARK_BASE_URL for international
.log_level // Set log level
.request_timeout // Request timeout
.enable_token_cache // Enable token caching
.build;
Marketplace App Configuration
let config = builder
.marketplace_app // Enable marketplace mode
.app_ticket // Required for marketplace apps
.build;
Helpdesk Configuration
let config = builder
.helpdesk
.build;
Client Options
use ;
use ;
let client = new
.with
.with
.with
.with
.build?;
API Reference
Operation IDs
Operations use the format: {service}.{version}.{resource}.{method}
Examples:
im.v1.messages.create- Send messageim.v1.chat.list- List chatscontact.v3.user.get- Get user infoauth.v3.tenant_access_token.internal.post- Get tenant token
Typed API Wrappers
use all_services;
// Get chat info
let builder = get
.query_param;
// List users
let builder = list
.query_param
.query_param;
Examples
See the examples/ directory:
get_token.rs- Get tenant access tokensend_message.rs- Send a messageget_user.rs- Get user informationim_v1_message.rs- IM message operationsdrive_v1_file.rs- Drive file operationscalendar_v4.rs- Calendar operationsdocx_v1.rs- Docx document operationssheets_v3.rs- Sheets operationsbitable_v1.rs- Bitable operationsapproval_v4.rs- Approval operationsevent_server.rs- Event handling servercard_handler.rs- Card callback serverwebsocket_client.rs- WebSocket clientfull_app.rs- End-to-end app example (client + event + card)
Run examples:
# Set environment variables
# Run example
# Run server example (requires server feature)
# Run websocket example (requires websocket feature)
Documentation
- Usage guide:
docs/USAGE.md - FAQ:
docs/FAQ.md - Migration guide:
docs/MIGRATION.md - Best practices:
docs/BEST_PRACTICES.md
Error Handling
use Error;
match client.operation.send.await
License
MIT License