lark-helper


Namelark-helper JSON
Version 0.1.0.dev3 PyPI version JSON
download
home_pageNone
SummaryA Python library for interacting with Lark APIs, providing both synchronous and asynchronous interfaces
upload_time2025-07-22 07:28:08
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT
keywords lark api feishu bytedance collaboration bitable messaging async sync enterprise communication
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Lark Helper

[![PyPI version](https://badge.fury.io/py/lark-helper.svg)](https://badge.fury.io/py/lark-helper)
[![Python Support](https://img.shields.io/pypi/pyversions/lark-helper.svg)](https://pypi.org/project/lark-helper/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

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)

```bash
pip install lark-helper
```

### Using pip with extras

```bash
# 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)

```bash
uv pip install lark-helper
```

## Quick Start

### Synchronous Usage

```python
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

```python
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:

```python
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:

```bash
export LARK_APP_ID="your_app_id"
export LARK_APP_SECRET="your_app_secret"
```

### Error Handling

The library provides comprehensive error handling:

```python
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

```bash
# 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

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=lark_helper

# Run async tests
pytest -m asyncio
```

### Code Quality

```bash
# Format code
ruff format

# Lint code
ruff check

# Type checking
mypy src/lark_helper
```

### Building and Publishing

```bash
# 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](LICENSE) file for details.

## PyPI Package

This package is available on PyPI:

- **Package Page**: [lark-helper on PyPI](https://pypi.org/project/lark-helper/)

## Related Projects

- [lark-oapi](https://github.com/larksuite/oapi-sdk-python) - Official Lark Open API SDK
- [Lark Developer Documentation](https://open.feishu.cn/document/)

---

Made with ❤️ for the Lark developer community

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "lark-helper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": "philo-veritas <edison.gee.lan@gmail.com>",
    "keywords": "lark, api, feishu, bytedance, collaboration, bitable, messaging, async, sync, enterprise, communication",
    "author": null,
    "author_email": "philo-veritas <edison.gee.lan@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/72/73/dd3b1129dc83ec16060c39c180e14451dbb8619e3fe3a5a68f9482733932/lark_helper-0.1.0.dev3.tar.gz",
    "platform": null,
    "description": "# Lark Helper\n\n[![PyPI version](https://badge.fury.io/py/lark-helper.svg)](https://badge.fury.io/py/lark-helper)\n[![Python Support](https://img.shields.io/pypi/pyversions/lark-helper.svg)](https://pypi.org/project/lark-helper/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA Python library for interacting with Lark (Feishu) APIs, providing both synchronous and asynchronous interfaces for seamless integration with Lark's collaboration platform.\n\n## Features\n\n- **Dual Interface Support**: Both synchronous and asynchronous API interfaces\n- **Comprehensive API Coverage**: Support for Bitable, Messaging, File operations, and more\n- **Token Management**: Automatic tenant access token management with refresh handling\n- **Type Safety**: Full type hints and Pydantic model validation\n- **Easy Integration**: Simple and intuitive API design\n- **Enterprise Ready**: Built for production use with proper error handling\n\n## Installation\n\n### Using pip (recommended)\n\n```bash\npip install lark-helper\n```\n\n### Using pip with extras\n\n```bash\n# Install with development dependencies\npip install \"lark-helper[dev]\"\n\n# Install with testing dependencies\npip install \"lark-helper[test]\"\n\n# Install with documentation dependencies\npip install \"lark-helper[docs]\"\n```\n\n### Using uv (faster installation)\n\n```bash\nuv pip install lark-helper\n```\n\n## Quick Start\n\n### Synchronous Usage\n\n```python\nfrom lark_helper.token_manager import TenantAccessTokenManager\nfrom lark_helper.v1 import message, bitable\n\n# Initialize token manager\ntoken_manager = TenantAccessTokenManager(\n    app_id=\"your_app_id\",\n    app_secret=\"your_app_secret\"\n)\n\n# Send a message\nfrom lark_helper.constants.message import MessageType, ReceiveIdType\n\nmessage_id = message.send_message(\n    token_manager=token_manager,\n    receive_id=\"user_id_or_chat_id\",\n    receive_id_type=ReceiveIdType.USER_ID,\n    message_type=MessageType.TEXT,\n    content=\"Hello from Lark Helper!\"\n)\n```\n\n### Asynchronous Usage\n\n```python\nimport asyncio\nfrom lark_helper.token_manager import TenantAccessTokenManager\nfrom lark_helper.v1_async import message, bitable\n\nasync def main():\n    # Initialize token manager\n    token_manager = TenantAccessTokenManager(\n        app_id=\"your_app_id\",\n        app_secret=\"your_app_secret\"\n    )\n    \n    # Send a message asynchronously\n    message_id = await message.send_message(\n        token_manager=token_manager,\n        receive_id=\"user_id_or_chat_id\",\n        receive_id_type=ReceiveIdType.USER_ID,\n        message_type=MessageType.TEXT,\n        content=\"Hello from Lark Helper!\"\n    )\n    \n    # Work with Bitable asynchronously\n    record = await bitable.add_bitable_record(\n        token_manager=token_manager,\n        app_token=\"your_app_token\",\n        table_id=\"your_table_id\",\n        fields={\"Name\": \"Jane Doe\", \"Email\": \"jane@example.com\"}\n    )\n\n# Run the async function\nasyncio.run(main())\n```\n\n## API Coverage\n\n### Messaging\n\n- Send messages (text, rich text, images, etc.)\n- Message content formatting\n- Support for different recipient types (user, chat, email)\n\n### Bitable (Multi-dimensional Tables)\n\n- Create, read, update, delete records\n- Search and filter records\n- Manage table views\n- Handle field types and validation\n\n### File Operations\n\n- Upload and download files\n- File metadata management\n- Batch file operations\n\n### User Management\n\n- User information retrieval\n- User search and lookup\n\n### Document Operations\n\n- Document creation and editing\n- Content management\n- Collaborative editing support\n\n## Token Management\n\nThe library automatically handles Lark tenant access tokens:\n\n```python\nfrom lark_helper.token_manager import TenantAccessTokenManager\n\ntoken_manager = TenantAccessTokenManager(\n    app_id=\"your_app_id\",\n    app_secret=\"your_app_secret\"\n)\n\n# Token is automatically refreshed when needed\n# No manual token management required\n```\n\n## Configuration\n\n### Environment Variables\n\nYou can set your Lark app credentials using environment variables:\n\n```bash\nexport LARK_APP_ID=\"your_app_id\"\nexport LARK_APP_SECRET=\"your_app_secret\"\n```\n\n### Error Handling\n\nThe library provides comprehensive error handling:\n\n```python\nfrom lark_helper.exception import LarkHelperException\n\ntry:\n    result = message.send_message(...)\nexcept LarkHelperException as e:\n    print(f\"Lark API error: {e}\")\nexcept Exception as e:\n    print(f\"Unexpected error: {e}\")\n```\n\n## Requirements\n\n- Python 3.12+\n- aiohttp (for async operations)\n- requests (for sync operations)\n- pydantic (for data validation)\n- lark-oapi (official Lark SDK)\n\n## Development\n\n### Setting up Development Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/philo-veritas/lark-helper.git\ncd lark-helper\n\n# Create virtual environment\nuv venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n\n# Install development dependencies\nuv pip install -e \".[dev]\"\n```\n\n### Running Tests\n\n```bash\n# Run all tests\npytest\n\n# Run with coverage\npytest --cov=lark_helper\n\n# Run async tests\npytest -m asyncio\n```\n\n### Code Quality\n\n```bash\n# Format code\nruff format\n\n# Lint code\nruff check\n\n# Type checking\nmypy src/lark_helper\n```\n\n### Building and Publishing\n\n```bash\n# Build the package\npython -m build\n\n# Check the built package\ntwine check dist/*\n\n# Upload to TestPyPI (for testing)\ntwine upload --repository testpypi dist/*\n\n# Upload to PyPI (for production)\ntwine upload dist/*\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## PyPI Package\n\nThis package is available on PyPI:\n\n- **Package Page**: [lark-helper on PyPI](https://pypi.org/project/lark-helper/)\n\n## Related Projects\n\n- [lark-oapi](https://github.com/larksuite/oapi-sdk-python) - Official Lark Open API SDK\n- [Lark Developer Documentation](https://open.feishu.cn/document/)\n\n---\n\nMade with \u2764\ufe0f for the Lark developer community\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python library for interacting with Lark APIs, providing both synchronous and asynchronous interfaces",
    "version": "0.1.0.dev3",
    "project_urls": {
        "Homepage": "https://github.com/philo-veritas/lark-helper"
    },
    "split_keywords": [
        "lark",
        " api",
        " feishu",
        " bytedance",
        " collaboration",
        " bitable",
        " messaging",
        " async",
        " sync",
        " enterprise",
        " communication"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "70921ed64ca9caceea12ff5a1ab9983146804f8c4226b5b0ecc91c9edb394306",
                "md5": "8de79dcf2883645153eeb74bb8b4c21b",
                "sha256": "bf1da253ae7eb37035c5d512511f7c5d0918bc916731f7858f8df82f3a000be5"
            },
            "downloads": -1,
            "filename": "lark_helper-0.1.0.dev3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8de79dcf2883645153eeb74bb8b4c21b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 31560,
            "upload_time": "2025-07-22T07:28:06",
            "upload_time_iso_8601": "2025-07-22T07:28:06.819662Z",
            "url": "https://files.pythonhosted.org/packages/70/92/1ed64ca9caceea12ff5a1ab9983146804f8c4226b5b0ecc91c9edb394306/lark_helper-0.1.0.dev3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7273dd3b1129dc83ec16060c39c180e14451dbb8619e3fe3a5a68f9482733932",
                "md5": "6acf9503f78ca2aed317d17167f51b59",
                "sha256": "8973444c85caaf3053235f79dab8698dfe8864c0e340ade98202fc4220d4888c"
            },
            "downloads": -1,
            "filename": "lark_helper-0.1.0.dev3.tar.gz",
            "has_sig": false,
            "md5_digest": "6acf9503f78ca2aed317d17167f51b59",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 26912,
            "upload_time": "2025-07-22T07:28:08",
            "upload_time_iso_8601": "2025-07-22T07:28:08.049614Z",
            "url": "https://files.pythonhosted.org/packages/72/73/dd3b1129dc83ec16060c39c180e14451dbb8619e3fe3a5a68f9482733932/lark_helper-0.1.0.dev3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-22 07:28:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "philo-veritas",
    "github_project": "lark-helper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "lark-helper"
}
        
Elapsed time: 1.28361s