• Stars
    star
    579
  • Rank 70,466 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

LINE Messaging API SDK for Java

LINE Messaging API SDK for Java

Maven Central javadoc

Introduction

The LINE Messaging API SDK for Java 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.

Requirements

This library requires Java 17 or later.

Installation

We've uploaded this library to the Maven Central Repository. You can install the modules using Maven or Gradle.

https://central.sonatype.com/search?smo=true&q=com.linecorp.bot

Gradle (Kotlin) example

implementation("com.linecorp.bot:line-bot-messaging-api-client:<VERSION>")
implementation("com.linecorp.bot:line-bot-insight-client:<VERSION>")
implementation("com.linecorp.bot:line-bot-manage-audience-client:<VERSION>")
implementation("com.linecorp.bot:line-bot-module-attach-client:<VERSION>")
implementation("com.linecorp.bot:line-bot-module-client:<VERSION>")
implementation("com.linecorp.bot:line-bot-shop-client:<VERSION>")
implementation("com.linecorp.bot:line-channel-access-token-client:<VERSION>")
implementation("com.linecorp.bot:line-liff-client:<VERSION>")

implementation("com.linecorp.bot:line-bot-webhook:<VERSION>")
implementation("com.linecorp.bot:line-bot-parser:<VERSION>") // You don't need to depend on this explicitly.

implementation("com.linecorp.bot:line-bot-spring-boot-webmvc:<VERSION>")
implementation("com.linecorp.bot:line-bot-spring-boot-client:<VERSION>") // If you want to write spring-boot API client
implementation("com.linecorp.bot:line-bot-spring-boot-handler:<VERSION>") // You don't need to depend on this explicitly.
implementation("com.linecorp.bot:line-bot-spring-boot-web:<VERSION>") // You don't need to depend on this explicitly.

Sample code

This project contains the following sample projects:

Spring Boot integration

The line-bot-spring-boot module lets you build a bot application as a Spring Boot application.

package com.example.bot.spring.echo;

import java.util.List;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.linecorp.bot.messaging.client.MessagingApiClient;
import com.linecorp.bot.messaging.model.ReplyMessageRequest;
import com.linecorp.bot.messaging.model.TextMessage;
import com.linecorp.bot.spring.boot.handler.annotation.EventMapping;
import com.linecorp.bot.spring.boot.handler.annotation.LineMessageHandler;
import com.linecorp.bot.webhook.model.Event;
import com.linecorp.bot.webhook.model.MessageEvent;
import com.linecorp.bot.webhook.model.TextMessageContent;

@SpringBootApplication
@LineMessageHandler
public class EchoApplication {
    private final MessagingApiClient messagingApiClient;

    public static void main(String[] args) {
        SpringApplication.run(EchoApplication.class, args);
    }

    public EchoApplication(MessagingApiClient messagingApiClient) {
        this.messagingApiClient = messagingApiClient;
    }

    @EventMapping
    public void handleTextMessageEvent(MessageEvent<TextMessageContent> event) {
        System.out.println("event: " + event);
        final String originalMessageText = ((TextMessageContent) event.message()).text();
        messagingApiClient.replyMessage(
            new ReplyMessageRequest.Builder(event.replyToken(), List.of(new TextMessage(originalMessageText)))
                .build()
        );
    }

    @EventMapping
    public void handleDefaultMessageEvent(Event event) {
        System.out.println("event: " + event);
    }
}

How do I use a proxy server?

You can use a proxy with this module.

api = MessagingApiClient.builder("MY_OWN_TOKEN")
        .apiEndPoint(URI.create("https://api.line.me/"))
        .proxy(new Proxy(Proxy.Type.HTTP,
                new InetSocketAddress("proxy.example.com", 8080)
        ))
        .build();

Note: You don't need to use an add-on like Fixie to have static IP addresses for proxy servers. You can make API calls without entering IP addresses on the server IP whitelist.

How to get x-line-request-id header and error message

You may need to store the x-line-request-id header obtained as a response from several APIs. In this case, you can get it from Result<T>.

Result<Object> apiResponse = messagingApiClient
    .narrowcast(retryKey, new NarrowcastRequest.Builder(messages).build())
    .get();
System.out.println("x-line-request-id: " + apiResponse.requestId());

You can get error messages from MessagingApiClientException when you use MessagingApiClient. Each client defines its own exception class.

try {
    messagingApiClient.replyMessage(new ReplyMessage(replyToken, messages));
} catch (ExecutionException e) {
    if (e.getCause() instanceof MessagingApiClientException){
        MessagingApiClientException exception=(MessagingApiClientException)e.getCause();
        System.out.println("Error http status code: " + exception.getCode());
        System.out.println("Error response: " + exception.getDetails());
        System.out.println("Error message: " + exception.getMessage());
    }
}

When you need to get x-line-accepted-request-id header from error response, you can get it: exception.getHeader("x-line-accepted-request-id").

Help and media

FAQ: https://developers.line.biz/en/faq/

Community Q&A: https://www.line-community.me/questions

News: https://developers.line.biz/en/news/

Twitter: @LINE_DEV

Versioning

This project respects semantic versioning.

See http://semver.org/.

SDK Lifecycle Documentation

The lifecycle of the Software Development Kit (SDK) follows certain stages that ensure optimal support and improvements for developers. The developers of the SDK manage different versions of the SDK following the principles outlined below:

  • The SDK developers only add features to the latest major version (active development version).
  • The SDK developers accept patches for the major versions in the maintenance phase. The maintenance phase continues for six months after the release of the next major version.
  • The SDK developers do not accept patches for major versions once the maintenance phase has ended.

These principles ensure that the SDK remains up-to-date, secure, and reliable, while also encouraging developers to adopt the latest version.

Here's a brief summary of the current status of each version:

Version Release Date Status Active Development Until End of Life Date
7.x May 18, 2023 Active Development TBD TBD
6.x February 6, 2023 Maintenance Phase May 18, 2023 November 18, 2023
5.x August 4, 2022 Maintenance Phase(โ€ป) February 6, 2023 November 18, 2023

"Active Development Until" indicates when the version will transition into the maintenance phase, while "End of Life Date" indicates when the version will no longer be supported.

โ€ป: Exceptionally extended deadline

Version 7.x

LINE's SDK developer team decides to generate SDK code based on OpenAPI spec. As a result, LINE bot sdk 7.x is not compatible with 6.x. But it can follow the future API changes very quickly.

  • line-bot-model and line-bot-api-client are splitted to line-bot-webhook and clients/ modules
  • line-bot-servlet is no longer supported.
  • line-bot-cli is no longer supported.
  • line-bot-spring-boot was splitted.
    • Splitted to following modules.
      • line-bot-spring-boot-client is a client bean configuration module.
        • If you want to write spring-boot API client,
      • line-bot-spring-boot-handler is a handler configuration.
        • You don't need to depend this explicitly.
      • line-bot-spring-boot-web is a spring-web binding.
        • You don't need to depend this explicitly.
      • line-bot-spring-boot-webmvc is a spring-webmvc binding.
        • usually, you want to depend on this module.

Version 5.x and 6.x

This library provides the Spring Boot binding. And there are some incompatible changes between Spring Boot 2.x and 3.x. As a result, line-bot-sdk-java maintainers maintain two maintenance lines until the end of the life of Spring Boot 2.x.

  • line-bot-sdk-java 6.x supports Spring Boot 3.x and Jakarta EE, Java 17+(Branch: master).
  • line-bot-sdk-java 5.x supports Spring Boot 2.x and Java EE, Java 8+(branch: maint/5.x).

Spring Boot 2.x is scheduled for retirement on 2023/11/18. This means that line-bot-sdk-java 5.x will be retired on 2023/11/18. https://endoflife.date/spring-boot

Contributing

Please check CONTRIBUTING before making a contribution.

License

Copyright (C) 2016 LINE Corp.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

armeria

Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Java
4,491
star
2

line-bot-sdk-python

LINE Messaging API SDK for Python
Python
1,720
star
3

promgen

Promgen is a configuration file generator for Prometheus
Python
1,003
star
4

line-bot-sdk-nodejs

LINE Messaging API SDK for Node.js
TypeScript
888
star
5

line-bot-sdk-go

LINE Messaging API SDK for Go
Go
843
star
6

line-sdk-ios-swift

Provides a modern way of implementing LINE APIs.
Swift
809
star
7

line-bot-sdk-php

LINE Messaging API SDK for PHP
PHP
680
star
8

centraldogma

Highly-available version-controlled service configuration repository based on Git, ZooKeeper and HTTP/2
Java
560
star
9

kotlin-jdsl

Kotlin library that makes it easy to build and execute queries without generated metamodel
Kotlin
534
star
10

line-bot-sdk-ruby

LINE Messaging API SDK for Ruby
Ruby
471
star
11

stellite

Stellite project is a client library and server application that offers an easy way to develop, build, and implement client/server running primarily over the QUIC protocol developed by Google as part of the Chromium project.
C++
470
star
12

line-fido2-server

FIDO2(WebAuthn) server officially certified by FIDO Alliance and Relying Party examples.
Java
447
star
13

garr

Collection of high performance, thread-safe, lock-free go data structures
Go
366
star
14

line-liff-v2-starter

This is a small web application that demonstrates the basic functionality of the LINE Front-end Framework (LIFF).
JavaScript
298
star
15

decaton

High throughput asynchronous task processing on Apache Kafka
Java
289
star
16

apng-drawable

A lightweight and fast Animated Portable Network Graphics (APNG) image decoder for Android
Kotlin
208
star
17

rules_apple_line

LINE's Apple rules for Bazel
Starlark
205
star
18

flutter_line_sdk

A Flutter plugin that lets developers access LINE's native SDKs in Flutter apps with Dart.
Dart
205
star
19

headver

SemVer compatible version specification that has {head}.{yearweek}.{build} system.
197
star
20

lich

A library collection that enhances the development of Android apps.
Kotlin
166
star
21

line-liff-starter

This is a small web application that demonstrates the basic functionality of the LINE Front-end Framework (LIFF).
JavaScript
135
star
22

armeria-examples

Armeria examples
Java
135
star
23

line-login-starter

LINE Login starter application
Java
130
star
24

conflr

Post R Markdown documents to Confluence
R
130
star
25

clay

Clay is an Android library project that provides image trimming which is originally an UI component of LINE Creators Studio
Kotlin
120
star
26

line-sdk-android

LINE SDK for Android lets you integrate LINE into your Android app to create a more engaging experience for your users.
Java
119
star
27

line-simple-beacon

JavaScript
104
star
28

jnotebook_reader

๐Ÿƒ An awesome viewer to browse and render Jupyter Notebooks from local, Amazon S3, Google Cloud Storage or MinIO
JavaScript
101
star
29

line-sdk-unity

Provides a modern way of implementing LINE APIs in Unity games, for iOS and Android.
C#
96
star
30

line-things-starter

The sample codes for LINE Things Developer Trial
C++
91
star
31

feature-flag-android

A Gradle plugin to achieve feature flag based development for Android applications.
Kotlin
90
star
32

webpack.kr

Korean translation of webpack document
JavaScript
89
star
33

grow-loader

A webpack loader to split class methods by decorators
JavaScript
89
star
34

vue-pivot-table-plus

An enhanced pivot table component for Vue.js
Vue
76
star
35

line-platform-feedback

LINE Platform feedback
76
star
36

gradle-scripts

Sensible multi-project defaults for Gradle
75
star
37

gradle-multi-project-support

A collection of Gradle plugins to maintain the multi-project or multi-application in the mono-repo.
Kotlin
73
star
38

line-bot-sdk-perl

LINE Messaging API SDK for Perl
Perl
72
star
39

abc-kmm-location

Location Service Manager for Kotlin Multiplatform Mobile iOS and Android
Kotlin
63
star
40

ostracon

Ostracon, a consensus algorithm, is forked from Tendermint Core. We have added VRF to Tendermint BFT. It adds randomness to PoS Validator elections and improves security.
Go
60
star
41

liff-playground

An example app to show the usage of LIFF's API functions
TypeScript
60
star
42

conditional

A super lightweight library that helps you to compose multiple conditional expressions and make them asynchronous easily.
Java
54
star
43

lbm-sdk

A framework for building blockchains based LINE Blockchain Mainnet that is forked from cosmos-sdk
Go
53
star
44

line-openapi

OpenAPI spec of the LINE's Public APIs
JavaScript
52
star
45

line-sdk-starter-ios

A starter app demonstrating usage of the LINE iOS SDK.
Objective-C
50
star
46

centraldogma-go

Go client library for Central Dogma
Go
45
star
47

centraldogma-rs

Official Rust client for Central Dogma
Rust
45
star
48

zipkin-lens

An alternative UI for Zipkin (Distributed Tracing), this repo is no longer used as it's already merged into upstream, please go to https://github.com/openzipkin/zipkin/tree/master/zipkin-lens
JavaScript
44
star
49

liff-inspector

The universal DevTools for LIFF (WebView) browser
TypeScript
39
star
50

LINE-DistilBERT-Japanese

DistilBERT model pre-trained on 131 GB of Japanese web text. The teacher model is BERT-base that built in-house at LINE.
38
star
51

abc-kmm-notifications

Remote Notification Manager for Kotlin Multiplatform Mobile iOS and Android
Kotlin
37
star
52

create-liff-app

Start developing LIFF application with a simple CLI command.
TypeScript
36
star
53

clova-cek-sdk-nodejs

SDK of the Clova CEK for Node.js
TypeScript
34
star
54

line-sdk-starter-android-v2

A starter application that demonstrates how to use LINE SDK V2 for Android.
Java
34
star
55

lfb

LINE Financial Blockchain forked from gaia(https://github.com/cosmos/gaia)
Go
32
star
56

line-sdk-starter-android

A starter app demonstrating usage of the LINE Android SDK.
Java
31
star
57

kubectl-kustomize

Docker image with kubectl and kustomize
Dockerfile
30
star
58

demo-rich-menu-bot

Demo bot for using rich menus with the Messaging API
PHP
29
star
59

line-things-dev-board

LINE Things development board - Sample codes and schematics
HTML
29
star
60

recruiting-resources-jp

Go
27
star
61

line-sdk-starter-ios-v2

A starter application that demonstrates how to use LINE SDK for iOS.
Objective-C
27
star
62

liff-mock

LIFF Mock is a LIFF Plugin that make testing your LIFF app easy.
TypeScript
27
star
63

abc-kmm-shared-storage

A local storage management library for Kotlin Multiplatform Mobile iOS and Android
Kotlin
24
star
64

networking-sr

OpenStack Neutron plugin/drivers for Segment Routing IPv6
Python
24
star
65

gradle-multi-project-support-sample

This is a sample of build-recipe-plugin in gradle-multi-project-support
Kotlin
24
star
66

line-api-use-case-messaging-api

LINE Messaging API demo application provided by LINE API Use Case
Python
24
star
67

line-blockchain-developers-sdk-js

Javascript library for line blockchain developers
TypeScript
23
star
68

blockchain-sample-link-cinema

A sample service of LINE Blockchain, demonstrating how to utilize LINE Blockchain Developers and LINE BITMAX Wallet.
Go
22
star
69

line-api-use-case-reservation-hairsalon

Hair salon reservation demo application provided by LINE API Use Case
Python
22
star
70

clova-cek-sdk-swift

SDK of the Clova CEK for Swift
Swift
20
star
71

clova-cek-sdk-python

SDK of the Clova CEK for Python
Python
19
star
72

abc-kmm-analytics-tools

Analytics Tools for Kotlin Multiplatform Mobile iOS and Android
Kotlin
17
star
73

BC-node-server-sample

BusinessConnect sample server with NodeJS
JavaScript
16
star
74

centraldogma-python

Python client library for Central Dogma
Python
16
star
75

cosmwasm

Fast and reusable WebAssembly smart contract runtime(and library) for lbm-sdk.
Rust
15
star
76

gorocksdb

A `rocksdb` wrapper for golang applications. This is forked from https://github.com/tecbot/gorocksdb.
Go
15
star
77

line-bot-sample-ms

C#
14
star
78

iavl

Merkleized IAVL+ Tree implementation in Go forked from cosmos/iavl(https://github.com/cosmos/iavl)
Go
14
star
79

Meta-AI-Video-Similarity-Challenge-3rd-Place-Solution

The 3rd Place Solution of the Meta AI Video Similarity Challenge : Descriptor Track and Matching Track.
Python
14
star
80

clova-cek-sdk-java

SDK of the Clova CEK for Java
Java
13
star
81

clova-cek-sdk-elixir

SDK of the Clova CEK for Elixir
Elixir
13
star
82

tm-db

Common database interface for various database backends for Ostracon and LBM SDK. This is forked from Tendermint tm-db(https://github.com/tendermint/tm-db)
Go
13
star
83

line-api-use-case-table-order

Table order demo application provided by LINE API Use Case
Python
13
star
84

wasmvm

Go bindings to the CosmWasm smart contract framework. In particular, it allows you to easily compile, initialize, and execute these contracts from Go.
Go
13
star
85

line-api-use-case-reservation-Restaurant

Restaurant reservation demo application provided by LINE API Use Case
Python
12
star
86

line-bot-pyconkr2019

LINE Chatbot for PyCon KR 2019
Python
12
star
87

abc-user-feedback

TypeScript
12
star
88

blockchain-sample-mage-duel

A sample service implementing a card game using the blockchain, which can serve as a guide on tokenizing game money and items.
C#
11
star
89

line-blockchain-developers-sdk-kt

Kotlin library for line blockchain developers
Kotlin
11
star
90

clova-extension-sample-dice

JavaScript
10
star
91

clova-cek-sdk-go

SDK of the Clova CEK for Go
Go
9
star
92

abc-kmm-h3

A library to convert Uber's H3 geo-index to LatLng vertices for Kotlin Multiplatform Mobile iOS and Android
C
9
star
93

clova-chatbot-web-kit

Implementation of WebChat with CLOVA Chatbot
JavaScript
8
star
94

line-api-use-case-liff

LINE LIFF demo application provided by LINE API Use Case
CSS
8
star
95

line-api-use-case-line-login

LINE Login demo application provided by LINE API Use Case
Python
7
star
96

clova-developer-guide

Clova developer guide
CSS
6
star
97

line-conversion-api-server-tag

This is a server side tag template that can be installed into Google Server Side Tag Container and used to send conversion events to LINE Conversion API without additional implementation.
JavaScript
6
star
98

clova-cek-sdk-kotlin

The Clova CEK SDK for Kotlin
Kotlin
5
star
99

line-login-sample-for-spring-security

Spring Security + ่จญๅฎšใƒ•ใ‚กใ‚คใƒซใงๅง‹ใ‚ใ‚‹ LINE ใจใฎ ID Federation
Java
5
star
100

line-api-use-case-members-card-azure

Members card demo application provided by LINE API Use Case
C#
4
star