This release is a pre-release and may not be stable for production use.
Lark Helper
A Python library for interacting with Lark (Feishu) APIs, providing both synchronous and asynchronous interfaces for seamless integration with Lark's collaboration platform.
Features
- Dual Interface Support: Both synchronous and asynchronous API interfaces
- Comprehensive API Coverage: Support for Bitable, Messaging, File operations, and more
- Token Management: Automatic tenant access token management with refresh handling
- Type Safety: Full type hints and Pydantic model validation
- Easy Integration: Simple and intuitive API design
- Enterprise Ready: Built for production use with proper error handling
Installation
Using pip (recommended)
pip install lark-helper
Using pip with extras
# Install with development dependencies
pip install "lark-helper[dev]"
# Install with testing dependencies
pip install "lark-helper[test]"
# Install with documentation dependencies
pip install "lark-helper[docs]"
Using uv (faster installation)
uv pip install lark-helper
Quick Start
Synchronous Usage
from lark_helper.token_manager import TenantAccessTokenManager
from lark_helper.v1 import message, bitable
# Initialize token manager
token_manager = TenantAccessTokenManager(
app_id="your_app_id",
app_secret="your_app_secret"
)
# Send a message
from lark_helper.constants.message import MessageType, ReceiveIdType
message_id = message.send_message(
token_manager=token_manager,
receive_id="user_id_or_chat_id",
receive_id_type=ReceiveIdType.USER_ID,
message_type=MessageType.TEXT,
content="Hello from Lark Helper!"
)
Asynchronous Usage
import asyncio
from lark_helper.token_manager import TenantAccessTokenManager
from lark_helper.v1_async import message, bitable
async def main():
# Initialize token manager
token_manager = TenantAccessTokenManager(
app_id="your_app_id",
app_secret="your_app_secret"
)
# Send a message asynchronously
message_id = await message.send_message(
token_manager=token_manager,
receive_id="user_id_or_chat_id",
receive_id_type=ReceiveIdType.USER_ID,
message_type=MessageType.TEXT,
content="Hello from Lark Helper!"
)
# Work with Bitable asynchronously
record = await bitable.add_bitable_record(
token_manager=token_manager,
app_token="your_app_token",
table_id="your_table_id",
fields={"Name": "Jane Doe", "Email": "jane@example.com"}
)
# Run the async function
asyncio.run(main())
API Coverage
Messaging
- Send messages (text, rich text, images, etc.)
- Message content formatting
- Support for different recipient types (user, chat, email)
Bitable (Multi-dimensional Tables)
- Create, read, update, delete records
- Search and filter records
- Manage table views
- Handle field types and validation
File Operations
- Upload and download files
- File metadata management
- Batch file operations
User Management
- User information retrieval
- User search and lookup
Document Operations
- Document creation and editing
- Content management
- Collaborative editing support
Token Management
The library automatically handles Lark tenant access tokens:
from lark_helper.token_manager import TenantAccessTokenManager
token_manager = TenantAccessTokenManager(
app_id="your_app_id",
app_secret="your_app_secret"
)
# Token is automatically refreshed when needed
# No manual token management required
Configuration
Environment Variables
You can set your Lark app credentials using environment variables:
export LARK_APP_ID="your_app_id"
export LARK_APP_SECRET="your_app_secret"
Error Handling
The library provides comprehensive error handling:
from lark_helper.exception import LarkHelperException
try:
result = message.send_message(...)
except LarkHelperException as e:
print(f"Lark API error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
Requirements
- Python 3.12+
- aiohttp (for async operations)
- requests (for sync operations)
- pydantic (for data validation)
- lark-oapi (official Lark SDK)
Development
Setting up Development Environment
# Clone the repository
git clone https://github.com/philo-veritas/lark-helper.git
cd lark-helper
# Create virtual environment
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install development dependencies
uv pip install -e ".[dev]"
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=lark_helper
# Run async tests
pytest -m asyncio
Code Quality
# Format code
ruff format
# Lint code
ruff check
# Type checking
mypy src/lark_helper
Building and Publishing
# Build the package
python -m build
# Check the built package
twine check dist/*
# Upload to TestPyPI (for testing)
twine upload --repository testpypi dist/*
# Upload to PyPI (for production)
twine upload dist/*
License
This project is licensed under the MIT License - see the LICENSE file for details.
PyPI Package
This package is available on PyPI:
- Package Page: lark-helper on PyPI
Related Projects
- lark-oapi - Official Lark Open API SDK
- Lark Developer Documentation
Made with ❤️ for the Lark developer community
Metadata
Release files for lark-helper 0.1.0.dev20
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lark_helper-0.1.0.dev20.tar.gz | 34.0 kB | Without provenance | Details for lark_helper-0.1.0.dev20.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lark_helper-0.1.0.dev20-py3-none-any.whl | Python 3 | none | any | Details for lark_helper-0.1.0.dev20-py3-none-any.whl |
Total release size: 73.4 kB
Release files / lark_helper-0.1.0.dev20.tar.gz
| Download URL | lark_helper-0.1.0.dev20.tar.gz |
|---|---|
| Size | 34.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbdba814905f236e73e774e4c848de68fbc1cd785890e2a81b42409649d262a2
|
|
BLAKE2b-256 checksum How to use checksums |
05ee08e9ac87a7d3a69f19924a1c12e0454d17d7dfd72bbde0078b7798180da1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Release files / lark_helper-0.1.0.dev20-py3-none-any.whl
| Download URL | lark_helper-0.1.0.dev20-py3-none-any.whl |
|---|---|
| Size | 39.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db9ac685f23f062a1fcffa4b3c3758375714877bf700d057c648a142aa16915f
|
|
BLAKE2b-256 checksum How to use checksums |
2798f49887e4db0df7017a35af3bdb1d0154714abd25b03cb466a2a99da981f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Security for lark-helper 0.1.0.dev20
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.