A Python package that simplifies building bots against the LINE Messaging API. Install via pip and wire webhooks with Flask, FastAPI, or aiohttp.
Overview
LINE Bot SDK for Python wraps the LINE Messaging API so teams can build chat bots in Python. It targets Python 3.10 and later and is installed with pip as line-bot-sdk.
The current linebot.v3 modules are generated from the OpenAPI spec and are the maintained path forward; older linebot 2.x modules remain usable but are not updated. The SDK includes webhook parsing and handling (WebhookParser and WebhookHandler), signature verification, and clients for sending replies and rich messages. Sample echo bots exist for Flask, FastAPI, aiohttp, and a simple WSGI server.
Models support JSON deserialization (for example Flex Message layouts from the Flex Message Simulator). HTTP helpers expose response headers such as x-line-request-id when using with-http-info call variants. Official LINE API documentation covers the underlying HTTP API; this SDK focuses on Python integration.
Developers typically run a small HTTP app that receives LINE webhook POSTs, validates the X-Line-Signature header, and dispatches events to decorated handler functions for messages, follows, and other event types.
Key features
- WebhookParser and WebhookHandler
- OpenAPI-generated linebot.v3 clients
- Reply and messaging API wrappers
- Flex Message JSON deserialization
- HTTP response header helpers
- Invalid signature error handling
- Flask and FastAPI sample bots
Use cases
- LINE chat bot backends in Python
- Webhook callback servers
- Echo and kitchen-sink bot prototypes
- Rich menu and Flex Message bots