# line-bot-sdk

> LINE Messaging API SDK for Python

- **URL**: https://www.freshcrate.ai/projects/line-bot-sdk
- **Author**: RyosukeHasebe
- **Category**: Developer Tools
- **Latest version**: `3.23.0` (2026-04-21)
- **License**: Apache License 2.0
- **Source**: https://github.com/line/line-bot-sdk-python
- **Language**: Python
- **GitHub**: 2,099 stars, 1,048 forks
- **Registry**: pypi (`line-bot-sdk`)
- **Tags**: `pypi`

## Description

LINE Messaging API SDK for Python
=================================

|PyPI version|

SDK of the LINE Messaging API for Python.

Introduction
------------
The LINE Messaging API SDK for Python makes it easy to develop bots using LINE Messaging API, and you can create a sample bot within minutes.


Documentation
-------------

See the official API documentation for more information

English: https://developers.line.biz/en/docs/messaging-api/overview/

Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/

Requirements
------------

-  Python >= 3.10

Installation
------------

::

    $ pip install line-bot-sdk

Synopsis
--------

Usage:

.. code:: python

    from flask import Flask, request, abort

    from linebot.v3 import (
        WebhookHandler
    )
    from linebot.v3.exceptions import (
        InvalidSignatureError
    )
    from linebot.v3.messaging import (
        Configuration,
        ApiClient,
        MessagingApi,
        ReplyMessageRequest,
        TextMessage
    )
    from linebot.v3.webhooks import (
        MessageEvent,
        TextMessageContent
    )

    app = Flask(__name__)

    configuration = Configuration(access_token='YOUR_CHANNEL_ACCESS_TOKEN')
    handler = WebhookHandler('YOUR_CHANNEL_SECRET')


    @app.route("/callback", methods=['POST'])
    def callback():
        # get X-Line-Signature header value
        signature = request.headers['X-Line-Signature']

        # get request body as text
        body = request.get_data(as_text=True)
        app.logger.info("Request body: " + body)

        # handle webhook body
        try:
            handler.handle(body, signature)
        except InvalidSignatureError:
            app.logger.info("Invalid signature. Please check your channel access token/channel secret.")
            abort(400)

        return 'OK'


    @handler.add(MessageEvent, message=TextMessageContent)
    def handle_message(event):
        with ApiClient(configuration) as api_client:
            line_bot_api = MessagingApi(api_client)
            line_bot_api.reply_message_with_http_info(
                ReplyMessageRequest(
                    reply_token=event.reply_token,
                    messages=[TextMessage(text=event.message.text)]
                )
            )

    if __name__ == "__main__":
        app.run()

API
---

See `linebot/v3/messaging/docs <linebot/v3/messaging/docs/MessagingApi.md>`__ . Other docs are in ``linebot/v3/<feature>/docs/*.md``.


Webhook
-------

WebhookParser
~~~~~~~~~~~~~

※ You can use WebhookParser

\_\_init\_\_(self, channel\_secret, skip\_signature\_verification=lambda: False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    parser = linebot.v3.WebhookParser('YOUR_CHANNEL_SECRET')

    # or with skip_signature_verification option
    parser = linebot.v3.WebhookParser(
        'YOUR_CHANNEL_SECRET',
        skip_signature_verification=lambda: False

parse(self, body, signature, as_payload=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Parses the webhook body, and returns a list of Event objects or a WebhookPayload object (depending on as_payload).
If the signature does NOT match, ``InvalidSignatureError`` is raised.

.. code:: python

    events = parser.parse(body, signature)

    for event in events:
        do_something(event)

.. code:: python

    payload = parser.parse(body, signature, as_payload=True)

    for event in payload.events:
        do_something(payload.event, payload.destination)

WebhookHandler
~~~~~~~~~~~~~~

※ You can use WebhookHandler

\_\_init\_\_(self, channel\_secret, skip\_signature\_verification=lambda: False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

    handler = linebot.v3.WebhookHandler('YOUR_CHANNEL_SECRET')

    # or with skip_signature_verification option
    handler = linebot.v3.WebhookHandler(
        'YOUR_CHANNEL_SECRET',
        skip_signature_verification=lambda: False

handle(self, body, signature)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Handles webhooks with **handlers** added
by the decorators `add <#add-self-event-message-none>`__ and `default <#default-self>`__.
If the signature does NOT match, ``InvalidSignatureError`` is raised.

.. code:: python

    handler.handle(body, signature)

add(self, event, message=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Add a **handler** method by using this decorator.

.. code:: python

    @handler.add(MessageEvent, message=TextMessage)
    def handle_message(event):
        line_bot_api.reply_message(
            ReplyMessageRequest(
                reply_token=event.reply_token,
                messages=[TextMessage(text=event.message.text)]
            )
        )

When the event is an instance of MessageEvent and event.message is an instance of TextMessage,
this handler method is called.

.. code:: python

    @handler.add(MessageEvent)
    def handle_message(event, destination):
        # do something

If the ar

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `3.23.0` | 2026-04-21 | Low | Imported from PyPI (3.23.0) |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |
| `v3.23.0` | 2026-04-07 | Medium | <!-- Release notes generated using configuration in .github/release.yml at master -->  ## What's Changed  ### Added feature This release adds wrapper methods for `ChannelAccessToken#issue_stateless_channel_token`, making stateless channel access token issuance simpler for both JWT assertion and client secret authentication. With this release, you don't have to pass empty strings (`''`) for unused parameters.  ```diff - token = api.issue_stateless_channel_token( -     grant_type='client_ |

## Citation

- HTML: https://www.freshcrate.ai/projects/line-bot-sdk
- Markdown: https://www.freshcrate.ai/projects/line-bot-sdk.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/line-bot-sdk/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
