SDKs overview

Line provides Software Development Kits (SDKs) and client libraries to facilitate integration with its various APIs, primarily the Line Messaging API. These SDKs abstract the underlying HTTP requests, authentication, and response parsing, allowing developers to interact with Line's services using native language constructs rather than direct API calls. The official SDKs support several popular programming languages, ensuring broader accessibility for developers aiming to build applications that connect with Line's user base, particularly in the Asian market.

The SDKs are designed to streamline common development tasks, such as sending various message types (text, images, templates), managing user profiles, handling webhooks, and implementing Line Login for user authentication. By leveraging these libraries, developers can reduce the boilerplate code required to interact with Line's platform, accelerating the development of chatbots, customer service integrations, and marketing tools.

Official SDKs by language

Line maintains official SDKs for a range of programming languages, which are recommended for interacting with the Line platform due to their comprehensive features and direct support from Line. These SDKs are regularly updated to reflect changes in the Line Messaging API reference and other service APIs.

Language Package Name Maturity Key Features
Node.js @line/bot-sdk Stable Messaging API, Webhook handling, Line Login integration
Go github.com/line/line-bot-sdk-go Stable Messaging API client, Event processing
PHP line/line-bot-sdk Stable Messaging API client, Signature validation
Ruby line-bot-api Stable Messaging API client, Rich message support
Python line-bot-sdk Stable Messaging API, Flask example integration
Java line-bot-sdk Stable Messaging API client, Spring Boot compatibility

Installation

Installation of Line's official SDKs typically follows standard package management practices for each respective language. Below are common installation commands:

Node.js

npm install @line/bot-sdk

For Node.js projects, the @line/bot-sdk package is installed via npm, the Node package manager. This package includes utilities for the Line Messaging API and webhook handling. Further details can be found in the Line Node.js SDK documentation.

Go

go get github.com/line/line-bot-sdk-go

Go developers can retrieve the SDK using the go get command, which fetches the package from its Git repository and installs it into the Go module cache. The Line Go SDK overview provides additional setup instructions.

PHP

composer require line/line-bot-sdk

PHP projects utilize Composer for dependency management. The composer require command adds the Line Bot SDK to the project's dependencies. The Line PHP SDK documentation details usage and configuration.

Ruby

gem install line-bot-api

Ruby projects typically manage dependencies with RubyGems. The gem install command installs the line-bot-api gem. Refer to the Line Ruby SDK guide for comprehensive usage examples.

Python

pip install line-bot-sdk

Python developers use pip, the Python package installer, to install the line-bot-sdk. This SDK is compatible with various Python web frameworks, as outlined in the Line Python SDK overview.

Java

<dependency>
    <groupId>com.linecorp.bot</groupId>
    <artifactId>line-bot-api-client</artifactId>
    <version>6.0.0</version> 
</dependency>

For Java projects, the Line Bot SDK is typically included as a Maven or Gradle dependency. The snippet above shows a Maven dependency configuration. Developers should consult the Line Java SDK documentation for the latest version and detailed setup.

Quickstart example

This Node.js example demonstrates how to create a basic Line Messaging API bot that echoes received text messages. This quickstart assumes you have already set up a Line Developers console account, created a Messaging API channel, and obtained your Channel Access Token and Channel Secret. For detailed setup, refer to the Line Messaging API getting started guide.

const express = require('express');
const line = require('@line/bot-sdk');

const config = {
  channelAccessToken: process.env.CHANNEL_ACCESS_TOKEN,
  channelSecret: process.env.CHANNEL_SECRET,
};

const client = new line.Client(config);
const app = express();

app.post('/webhook', line.middleware(config), (req, res) => {
  Promise
    .all(req.body.events.map(handleEvent))
    .then((result) => res.json(result))
    .catch((err) => {
      console.error(err);
      res.status(500).end();
    });
});

function handleEvent(event) {
  if (event.type !== 'message' || event.message.type !== 'text') {
    // ignore non-text-message event
    return Promise.resolve(null);
  }

  // create a echoing text message
  const echoMessage = {
    type: 'text',
    text: event.message.text,
  };

  // use reply API
  return client.replyMessage(event.replyToken, echoMessage);
}

const port = process.env.PORT || 3000;
app.listen(port, () => {
  console.log(`listening on ${port}`);
});

To run this example:

  1. Install Node.js and npm.
  2. Create a new directory for your project.
  3. Run npm init -y in your project directory.
  4. Install necessary packages: npm install express @line/bot-sdk dotenv. The dotenv package (not shown in the snippet but good practice) helps manage environment variables.
  5. Create a .env file with your CHANNEL_ACCESS_TOKEN and CHANNEL_SECRET.
  6. Save the code above as index.js.
  7. Run node index.js.
  8. Set up a webhook URL for your Line channel to point to your deployed application's /webhook endpoint. Tools like ngrok can be used for local development to expose your localhost to the internet.

This setup creates a basic server that listens for incoming Line webhook events. When a text message is received, the handleEvent function processes it and uses the Line client to reply with the same text message to the user.

Community libraries

Beyond the official SDKs, the Line developer community has contributed various libraries and tools that extend functionality or provide alternative implementations in languages not officially supported. These community-driven projects can offer specialized features, integrations with specific frameworks, or support for particular use cases.

While official SDKs are recommended for core integrations due to direct support and maintenance, community libraries can be valuable for niche requirements or preferred development environments. Developers should evaluate community libraries for active maintenance, documentation quality, and community support before integrating them into production systems, as their stability and security may vary compared to officially maintained SDKs. Resources like GitHub and various developer forums are common places to discover such tools.

For instance, some community efforts might focus on:

  • Specialized UI frameworks: Libraries that help render Line's Flex Messages or Rich Menus with more abstract components.
  • Cloud function integrations: Wrappers or examples for deploying Line bots directly to serverless platforms such as AWS Lambda or Google Cloud Functions.
  • Different language bindings: SDKs for languages like C#, Swift, or Kotlin, which may not have official Line SDKs.
  • Framework-specific connectors: Integrations designed specifically for web frameworks (e.g., Django for Python, Laravel for PHP) to simplify webhook routing and event handling.

The Line developer community actively shares code and knowledge, often found in public repositories and forums. Developers looking for specific tools or integrations beyond the official offerings are encouraged to explore these community resources.