Library / SDK
line/line-bot-sdk-python avatar
line/line-bot-sdk-python

line-bot-sdk-python: signature-checked webhooks, decorator handlers and a v3 namespace you must import from

LINE Messaging API SDK for Python

2,147 stars1,046 forksPythonApache-2.0

At a glance

What is it?
LINE's official Python SDK for the Messaging API wraps webhook verification, event dispatch and the reply and push client. Everything lives under linebot.v3, and the README examples disagree with each other in a few places.
Who is it for?
Adopt this SDK if you build a LINE bot in Python 3.10 or newer and want webhook verification and typed request models without writing them yourself. Skip it if your bot has to run on an older interpreter.
Can I use it commercially?
Yes. Apache-2.0 is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • line/line-bot-sdk-python2,147 ★ · +8
Star history
Repository2026-10-112026-11-25
line/line-bot-sdk-python2.1k2.1k

8 Stars in the last 45 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Everything you import sits under linebot.v3

The package is installed as line-bot-sdk and imported as linebot. The README's synopsis pulls from four v3 modules: linebot.v3 for WebhookHandler, linebot.v3.exceptions for InvalidSignatureError, linebot.v3.messaging for Configuration, ApiClient, MessagingApi, ReplyMessageRequest and TextMessage, and linebot.v3.webhooks for MessageEvent and TextMessageContent.

The split is by feature. Each area keeps its own documentation under linebot/v3/<feature>/docs/*.md, and the messaging API reference starts at linebot/v3/messaging/docs/MessagingApi.md.

Requirements are short. The README states Python 3.10 or newer, and install is one line:

code
pip install line-bot-sdk

The PyPI project carries the same name, and the repository homepage points there.

One decorator decides which handler runs

WebhookHandler takes the channel secret and exposes three methods. handle(body, signature) verifies the request and dispatches. add(event, message=None) registers a handler function by decorator. default() registers a fallback for events nobody else claimed.

Dispatch is by type. Registering @handler.add(MessageEvent, message=TextMessageContent) calls your function only when the event is a MessageEvent and its message is a text message. Leave out the message argument and every MessageEvent reaches the function.

Arity matters. A handler with two parameters receives the webhook request's destination as the second argument. A handler with zero parameters is called with no arguments, which the README shows for FollowEvent. A function with one parameter gets only the event.

If no handler matches, the default handler runs with the event as its argument. Without one registered, the README does not say what happens to an unmatched event, so register a default and log it while you are developing.

Signature verification is on unless you pass a lambda

Both WebhookHandler and WebhookParser accept channel_secret and an optional skip_signature_verification, whose default is lambda: False. Verification therefore runs on every request by default. When the X-Line-Signature header does not match the body, handle and parse raise InvalidSignatureError, and the README's Flask example catches it and returns 400.

The skip hook takes a callable, not a boolean, so it can depend on runtime state, for example a test environment. Whether it is wise to wire it to anything outside tests is a decision the README leaves to you.

The synopsis reads the raw body with request.get_data(as_text=True) before calling the handler, then passes that text and the signature header to handle. The same pairing applies to parse.

WebhookParser returns events when you want to dispatch yourself

If decorators are not your style, WebhookParser takes the same channel secret and parse(body, signature, as_payload=False) returns a list of Event objects. Pass as_payload=True and you get a WebhookPayload instead, with destination and events attributes.

code
parser = linebot.v3.WebhookParser('YOUR_CHANNEL_SECRET')
code
events = parser.parse(body, signature)

Use the payload route when you need the destination value. The README documents the shape of WebhookPayload in three lines and links to the LINE reference for the request body and the webhook event objects.

Two snippets in the parser section have typos worth knowing before you copy them. The as_payload example loops over payload.events but calls do_something(payload.event, payload.destination) with a singular event. The constructor examples for WebhookParser and WebhookHandler both leave the closing parenthesis off the skip_signature_verification variant.

Replies go through ApiClient and MessagingApi with a context manager

Sending messages starts from Configuration(access_token='YOUR_CHANNEL_ACCESS_TOKEN'). The synopsis wraps each call in with ApiClient(configuration) as api_client, builds MessagingApi(api_client), and sends with reply_message_with_http_info(ReplyMessageRequest(reply_token=event.reply_token, messages=[TextMessage(text=event.message.text)])).

The reply token comes from the incoming event. The request models are typed objects rather than dicts, and the dependencies explain why: requirements.txt includes pydantic >=2.0.3, <3. It also lists requests, urllib3, aiohttp, aenum, python_dateutil, Deprecated and future, each with a version range.

The handler example under add() uses line_bot_api.reply_message(...) while the main synopsis uses reply_message_with_http_info. Both names appear in the README, and it does not explain the difference in return value. Pick the one that matches the signature in linebot/v3/messaging/docs/MessagingApi.md.

For asynchronous work the repository ships an aiohttp-echo example.

Generated models: where from_json and the docs folders come from

The model classes and per-feature docs are not hand-written. The top level of the repository contains generate-code.py, a generator/ directory, a line-openapi entry registered through .gitmodules, and a .openapi-generator-ignore file. The setup.py file defines a CodegenCommand next to its PyTest class. Together they point at OpenAPI-driven code generation, with line-openapi supplying the API description.

One generated capability is called out in the README: every model has a from_json method that deserializes JSON into that model, including FlexMessage and RichMenu objects. That is the route for loading a rich menu or a flex layout you designed elsewhere.

Because the code is generated, changes to a model class belong in the generator inputs, not in the output. A pull request that edits a file under linebot/v3 by hand risks being overwritten the next time someone regenerates. CONTRIBUTING.md and a renovate.json5 for dependency updates sit in the same root.

Releases track API features, and six examples show the shapes

Recent tags follow LINE's API additions. v3.27.0, dated 2026-10-27, raises the URI Action URL length limit. v3.26.0, from 2026-09-29, supports templated LINE notification messages (PNP) and custom aggregation units. v3.25.0, from 2026-07-07, adds the Message Edited webhook. The last push to master landed on 2026-10-25 and the repository is not archived.

The examples folder covers five hosting styles and a utility: aiohttp-echo for asynchronous handling, fastapi-echo, flask-echo, flask-kitchensink as a larger Flask sample, simple-server-echo built on wsgiref.simple_server, and rich-menu, a script for switching rich menus. Start with the echo bot that matches your web framework, then replace the reply logic.

The SDK is Apache-2.0 licensed. It covers the Messaging API only, per its name and description, so features of other LINE services need other clients. Messages and API versions are documented at developers.line.biz in English and Japanese, and the README defers to those pages for the API itself.

Editorial conclusion

Adopt this SDK if you build a LINE bot in Python 3.10 or newer and want webhook verification and typed request models without writing them yourself. Skip it if your bot has to run on an older interpreter. Before writing handlers, open the README's two examples side by side, because they use TextMessage and TextMessageContent for the same filter and only one of them matches the current webhook models.

Frequently asked questions

How do I install the LINE Bot SDK for Python?

Run pip install line-bot-sdk. The README requires Python 3.10 or newer, and the package is published on PyPI as line-bot-sdk.

How does line-bot-sdk-python verify webhook requests?

WebhookHandler and WebhookParser take your channel secret and check the X-Line-Signature header against the request body. A mismatch raises InvalidSignatureError.

Which web frameworks do the line-bot-sdk-python examples use?

The examples folder has bots built on aiohttp, FastAPI, Flask and wsgiref.simple_server, plus a flask-kitchensink sample and a rich-menu switching script.

Official sources

  1. License: Apache-2.0
  2. line/line-bot-sdk-python on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/line-line-bot-sdk-python.svg)](https://hysenlabs.com/projects/line-line-bot-sdk-python)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/line-line-bot-sdk-python.svg)](https://hysenlabs.com/projects/line-line-bot-sdk-python)

Was this useful?