{"id":22100096,"url":"https://github.com/line/line-bot-sdk-java","last_synced_at":"2025-05-14T01:03:23.650Z","repository":{"id":7413480,"uuid":"56061422","full_name":"line/line-bot-sdk-java","owner":"line","description":"LINE Messaging API SDK for Java","archived":false,"fork":false,"pushed_at":"2025-04-14T02:04:27.000Z","size":31344,"stargazers_count":620,"open_issues_count":3,"forks_count":947,"subscribers_count":69,"default_branch":"master","last_synced_at":"2025-04-14T02:57:08.831Z","etag":null,"topics":["bot","java","kotlin","line","sdk","spring"],"latest_commit_sha":null,"homepage":"https://developers.line.biz/en/docs/messaging-api/overview/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/line.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-12T12:32:40.000Z","updated_at":"2025-04-14T02:03:54.000Z","dependencies_parsed_at":"2024-02-04T12:39:25.123Z","dependency_job_id":"ab4997a1-4cdc-47bd-a8db-d68c2952d7bc","html_url":"https://github.com/line/line-bot-sdk-java","commit_stats":{"total_commits":878,"total_committers":49,"mean_commits":"17.918367346938776","dds":0.7072892938496583,"last_synced_commit":"3348dd8ae0e7a1fa9c7bd106296900b68b762c2e"},"previous_names":[],"tags_count":89,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fline-bot-sdk-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fline-bot-sdk-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fline-bot-sdk-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fline-bot-sdk-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/line","download_url":"https://codeload.github.com/line/line-bot-sdk-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248813786,"owners_count":21165632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","java","kotlin","line","sdk","spring"],"created_at":"2024-12-01T05:11:55.459Z","updated_at":"2025-04-14T02:57:21.210Z","avatar_url":"https://github.com/line.png","language":"Java","readme":"# LINE Messaging API SDK for Java\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.linecorp.bot/line-bot-messaging-api-client/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.linecorp.bot/line-bot-messaging-api-client)\n[![javadoc](https://javadoc.io/badge2/com.linecorp.bot/line-bot-parser/javadoc.svg)](https://javadoc.io/doc/com.linecorp.bot/line-bot-parser)\n\n## Introduction\n\nThe LINE Messaging API SDK for Java makes it easy to develop bots using LINE Messaging API, and you can create a sample\nbot within minutes.\n\n## Documentation\n\nSee the official API documentation for more information.\n\n- English: https://developers.line.biz/en/docs/messaging-api/overview/\n- Japanese: https://developers.line.biz/ja/docs/messaging-api/overview/\n\n## Requirements\n\nThis library requires Java 17 or later.\n\n## Installation\n\nWe've uploaded this library to the Maven Central Repository. You can install the modules using Maven or Gradle.\n\nhttps://central.sonatype.com/search?smo=true\u0026q=com.linecorp.bot\n\n### Gradle (Kotlin) example\n\n```kotlin\nimplementation(\"com.linecorp.bot:line-bot-messaging-api-client:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-bot-insight-client:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-bot-manage-audience-client:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-bot-module-attach-client:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-bot-module-client:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-bot-shop-client:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-channel-access-token-client:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-liff-client:\u003cVERSION\u003e\")\n\nimplementation(\"com.linecorp.bot:line-bot-webhook:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-bot-parser:\u003cVERSION\u003e\") // You don't need to depend on this explicitly.\n\nimplementation(\"com.linecorp.bot:line-bot-spring-boot-webmvc:\u003cVERSION\u003e\")\nimplementation(\"com.linecorp.bot:line-bot-spring-boot-client:\u003cVERSION\u003e\") // If you want to write spring-boot API client\nimplementation(\"com.linecorp.bot:line-bot-spring-boot-handler:\u003cVERSION\u003e\") // You don't need to depend on this explicitly.\nimplementation(\"com.linecorp.bot:line-bot-spring-boot-web:\u003cVERSION\u003e\") // You don't need to depend on this explicitly.\n```\n\n## Sample code\n\nThis project contains the following sample projects:\n\n* [sample-spring-boot-echo](samples/sample-spring-boot-echo): A simple echo server.\n* [sample-spring-boot-kitchensink](samples/sample-spring-boot-kitchensink): Full featured sample code.\n* [sample-spring-boot-echo-kotlin](samples/sample-spring-boot-echo-kotlin): A simple echo server written in Kotlin.\n* [sample-manage-audience](samples/sample-manage-audience): A sample code for Manage Audience API.\n\n## Spring Boot integration\n\nThe line-bot-spring-boot module lets you build a bot application as a Spring Boot application.\n\n```java\npackage com.example.bot.spring.echo;\n\nimport java.util.List;\n\nimport org.springframework.boot.SpringApplication;\nimport org.springframework.boot.autoconfigure.SpringBootApplication;\n\nimport com.linecorp.bot.messaging.client.MessagingApiClient;\nimport com.linecorp.bot.messaging.model.ReplyMessageRequest;\nimport com.linecorp.bot.messaging.model.TextMessage;\nimport com.linecorp.bot.spring.boot.handler.annotation.EventMapping;\nimport com.linecorp.bot.spring.boot.handler.annotation.LineMessageHandler;\nimport com.linecorp.bot.webhook.model.Event;\nimport com.linecorp.bot.webhook.model.MessageEvent;\nimport com.linecorp.bot.webhook.model.TextMessageContent;\n\n@SpringBootApplication\n@LineMessageHandler\npublic class EchoApplication {\n    private final MessagingApiClient messagingApiClient;\n\n    public static void main(String[] args) {\n        SpringApplication.run(EchoApplication.class, args);\n    }\n\n    public EchoApplication(MessagingApiClient messagingApiClient) {\n        this.messagingApiClient = messagingApiClient;\n    }\n\n    @EventMapping\n    public void handleTextMessageEvent(MessageEvent\u003cTextMessageContent\u003e event) {\n        System.out.println(\"event: \" + event);\n        final String originalMessageText = ((TextMessageContent) event.message()).text();\n        messagingApiClient.replyMessage(\n            new ReplyMessageRequest.Builder(event.replyToken(), List.of(new TextMessage(originalMessageText)))\n                .build()\n        );\n    }\n\n    @EventMapping\n    public void handleDefaultMessageEvent(Event event) {\n        System.out.println(\"event: \" + event);\n    }\n}\n```\n\n## How do I use a proxy server?\n\nYou can use a proxy with this module.\n\n```java\napi = MessagingApiClient.builder(\"MY_OWN_TOKEN\")\n        .apiEndPoint(URI.create(\"https://api.line.me/\"))\n        .proxy(new Proxy(Proxy.Type.HTTP,\n                new InetSocketAddress(\"proxy.example.com\", 8080)\n        ))\n        .build();\n```\nNote: You don't need to use an add-on like Fixie to have static IP addresses for proxy servers. You can make API calls\nwithout entering IP addresses on the server IP whitelist.\n\n## How to get x-line-request-id header and error message\n\nYou 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\u003cT\u003e`.\n```java\nResult\u003cObject\u003e apiResponse = messagingApiClient\n    .narrowcast(retryKey, new NarrowcastRequest.Builder(messages).build())\n    .get();\nSystem.out.println(\"x-line-request-id: \" + apiResponse.requestId());\n```\n\nYou can get error messages from `MessagingApiClientException` when you use `MessagingApiClient`. Each client defines its own exception class.\n```java\ntry {\n    messagingApiClient.replyMessage(new ReplyMessage(replyToken, messages));\n} catch (ExecutionException e) {\n    if (e.getCause() instanceof MessagingApiClientException){\n        MessagingApiClientException exception=(MessagingApiClientException)e.getCause();\n        System.out.println(\"Error http status code: \" + exception.getCode());\n        System.out.println(\"Error response: \" + exception.getDetails());\n        System.out.println(\"Error message: \" + exception.getMessage());\n    }\n}\n```\nWhen you need to get `x-line-accepted-request-id` header from error response, you can get it: `exception.getHeader(\"x-line-accepted-request-id\")`.\n\n## Help and media\n\nFAQ: https://developers.line.biz/en/faq/\n\nNews: https://developers.line.biz/en/news/\n\n## Versioning\n\nThis project respects semantic versioning.\n\nSee http://semver.org/.\n\n## From version 7.x\n\nLINE's SDK developer team decides to generate SDK code based on OpenAPI spec.\nAs a result, LINE bot sdk 7.x is not compatible with 6.x. But it can follow the future API changes very quickly.\n\n- `line-bot-model` and `line-bot-api-client` are splitted to `line-bot-webhook` and `clients/` modules\n- `line-bot-servlet` is no longer supported.\n- `line-bot-cli` is no longer supported.\n- `line-bot-spring-boot` was splitted.\n    - Splitted to following modules.\n        - `line-bot-spring-boot-client` is a client bean configuration module.\n            - If you want to write spring-boot API client,\n        - `line-bot-spring-boot-handler` is a handler configuration.\n            - You don't need to depend this explicitly.\n        - `line-bot-spring-boot-web` is a spring-web binding.\n            - You don't need to depend this explicitly.\n        - `line-bot-spring-boot-webmvc` is a spring-webmvc binding.\n            - **usually, you want to depend on this module.**\n\n## Contributing\n\nPlease check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution.\n\n## License\n\n    Copyright (C) 2016 LINE Corp.\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fline%2Fline-bot-sdk-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fline%2Fline-bot-sdk-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fline%2Fline-bot-sdk-java/lists"}