{"id":13676092,"url":"https://github.com/line/line-bot-sdk-go","last_synced_at":"2026-04-01T18:30:26.376Z","repository":{"id":37664810,"uuid":"57121553","full_name":"line/line-bot-sdk-go","owner":"line","description":"LINE Messaging API SDK for Go","archived":false,"fork":false,"pushed_at":"2025-04-21T07:59:47.000Z","size":31513,"stargazers_count":909,"open_issues_count":6,"forks_count":238,"subscribers_count":53,"default_branch":"master","last_synced_at":"2025-04-21T08:42:08.750Z","etag":null,"topics":["bot","go","golang","line","sdk"],"latest_commit_sha":null,"homepage":"https://developers.line.biz/en/docs/messaging-api/overview/","language":"Go","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,"zenodo":null}},"created_at":"2016-04-26T11:07:05.000Z","updated_at":"2025-04-21T08:34:28.000Z","dependencies_parsed_at":"2024-04-03T06:27:56.794Z","dependency_job_id":"61593422-ed6d-4ea5-a80d-f9e3502d3c17","html_url":"https://github.com/line/line-bot-sdk-go","commit_stats":{"total_commits":599,"total_committers":77,"mean_commits":7.779220779220779,"dds":0.7896494156928213,"last_synced_commit":"95d70a1133425fa452b483e7e78e4c38a4775f2f"},"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fline-bot-sdk-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fline-bot-sdk-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fline-bot-sdk-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/line%2Fline-bot-sdk-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/line","download_url":"https://codeload.github.com/line/line-bot-sdk-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251426699,"owners_count":21587634,"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","go","golang","line","sdk"],"created_at":"2024-08-02T13:00:18.178Z","updated_at":"2026-04-01T18:30:26.365Z","avatar_url":"https://github.com/line.png","language":"Go","funding_links":[],"categories":["Go","Repositories"],"sub_categories":[],"readme":"# LINE Messaging API SDK for Go\n\n[![Build Status](https://github.com/line/line-bot-sdk-go/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/line/line-bot-sdk-go/actions)\n[![Go Reference](https://pkg.go.dev/badge/github.com/line/line-bot-sdk-go/v8/linebot.svg)](https://pkg.go.dev/github.com/line/line-bot-sdk-go/v8/linebot)\n[![Go Report Card](https://goreportcard.com/badge/github.com/line/line-bot-sdk-go)](https://goreportcard.com/report/github.com/line/line-bot-sdk-go)\n\n\n## Introduction\nThe LINE Messaging API SDK for Go makes it easy to develop bots using LINE Messaging API, and you can create a sample bot 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 Go 1.24 or later.\n\n## Installation ##\n\n```sh\n$ go get -u github.com/line/line-bot-sdk-go/v8/linebot\n```\n\n## Import all packages in your code ##\n```go\nimport (\n\t\"github.com/line/line-bot-sdk-go/v8/linebot\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/channel_access_token\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/insight\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/liff\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/manage_audience\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/messaging_api\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/module\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/module_attach\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/shop\"\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/webhook\"\n)\n\n```\n\n## Configuration ##\n\n```go\nimport (\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/messaging_api\"\n)\n\nfunc main() {\n\tbot, err := messaging_api.NewMessagingApiAPI(\n\t\tos.Getenv(\"LINE_CHANNEL_TOKEN\"),\n\t)\n\t...\n}\n\n```\n\n### Configuration with http.Client ###\n\nEvery client application allows configuration with WithHTTPClient and WithEndpoint.\n(For Blob client, configurations WithBlobHTTPClient and WithBlobEndpoint are also available.)\n\n```go\nclient := \u0026http.Client{}\nbot, err := messaging_api.NewMessagingApiAPI(\n\tos.Getenv(\"LINE_CHANNEL_TOKEN\"),\n\tmessaging_api.WithHTTPClient(client),\n)\n...\n```\n\n## Getting Started ##\n\nThe LINE Messaging API primarily utilizes the JSON data format. To parse the incoming HTTP requests, the `webhook.ParseRequest()` method is provided. This method reads the `*http.Request` content and returns a slice of pointers to Event Objects.\n\n```go\nimport (\n\t\"github.com/line/line-bot-sdk-go/v8/linebot/webhook\"\n)\n\ncb, err := webhook.ParseRequest(os.Getenv(\"LINE_CHANNEL_SECRET\"), req)\nif err != nil {\n\t// Handle any errors that occur.\n}\n```\n\nThe LINE Messaging API is capable of handling various event types. The Messaging API SDK automatically unmarshals these events into respective classes like `webhook.MessageEvent`, `webhook.FollowEvent`, and so on. You can easily check the type of the event and respond accordingly using a switch statement as shown below:\n\n\n```go\nfor _, event := range cb.Events {\n\tswitch e := event.(type) {\n\t\tcase webhook.MessageEvent:\n\t\t\t// Do Something...\n\t\tcase webhook.StickerMessageContent:\n\t\t\t// Do Something...\n\t}\n}\n```\n\nWe provide code [examples](./examples).\n- [EchoBot](./examples/echo_bot/server.go)\n  - a simple echo bot\n- [KitchenSink](./examples/kitchensink/server.go)\n  - a bot that handles many types of events\n- [EchoBotHandler](./examples/echo_bot_handler/server.go)\n  - A simple bot that automatically verifies signatures and only handles Webhook events\n- [DeliveryHelper](./examples/delivery_helper/main.go)\n- [InsightHelper](./examples/insight_helper/main.go)\n- [RichmenuHelper](./examples/richmenu_helper/main.go)\n\n### Receiver ###\n\nTo send a message to a user, group, or room, you need either an ID\n\n```go\nuserID := event.Source.UserId\ngroupID := event.Source.GroupId\nRoomID := event.Source.RoomId\n```\n\nor a reply token.\n\n```go\nreplyToken := event.ReplyToken\n```\n\n### Create message ###\n\nThe LINE Messaging API provides various types of message.\n\n```go\nbot.ReplyMessage(\n\t\u0026messaging_api.ReplyMessageRequest{\n\t\tReplyToken: e.ReplyToken,\n\t\tMessages: []messaging_api.MessageInterface{\n\t\t\tmessaging_api.TextMessage{\n\t\t\t\tText: replyMessage,\n\t\t\t},\n\t\t},\n\t},\n)\n```\n\n### Send message ###\n\nWith an ID, you can send message using ```PushMessage()```\n\n```go\nbot.PushMessage(\n\t\u0026messaging_api.PushMessageRequest{\n\t\tTo: \"U.......\",\n\t\tMessages: []messaging_api.MessageInterface{\n\t\t\tmessaging_api.TextMessage{\n\t\t\t\tText: pushMessage,\n\t\t\t},\n\t\t},\n\t},\n\t\"\", // x-line-retry-key\n)\n```\n\nWith a reply token, you can reply to messages using ```ReplyMessage()```\n\n```go\nbot.ReplyMessage(\n\t\u0026messaging_api.ReplyMessageRequest{\n\t\tReplyToken: e.ReplyToken,\n\t\tMessages: []messaging_api.MessageInterface{\n\t\t\tmessaging_api.TextMessage{\n\t\t\t\tText: replyMessage,\n\t\t\t},\n\t\t},\n\t},\n)\n```\n\n### How to get response header and error message ###\nYou may need to store the ```x-line-request-id``` header obtained as a response from several APIs. In this case, please use ```~WithHttpInfo```. You can get headers and status codes. The ```x-line-accepted-request-id``` or ```content-type``` header can also be obtained in the same way.\n\n```go\nresp, _, _ := app.bot.ReplyMessageWithHttpInfo(\n\t\u0026messaging_api.ReplyMessageRequest{\n\t\tReplyToken: replyToken,\n\t\tMessages: []messaging_api.MessageInterface{\n\t\t\tmessaging_api.TextMessage{\n\t\t\t\tText: \"Hello, world\",\n\t\t\t},\n\t\t},\n\t}, \n)\nlog.Printf(\"status code: (%v), x-line-request-id: (%v)\", resp.StatusCode, resp.Header.Get(\"x-line-request-id\"))\n\n```\n\nSimilarly, you can get specific error messages by using ```~WithHttpInfo```.\n\n```go\nresp, _, err := app.bot.ReplyMessageWithHttpInfo(\n    \u0026messaging_api.ReplyMessageRequest{\n        ReplyToken: replyToken + \"invalid\",\n        Messages: []messaging_api.MessageInterface{\n            messaging_api.TextMessage{\n                Text: \"Hello, world\",\n            },\n        },\n    },\n)\nif err != nil \u0026\u0026 resp.StatusCode \u003e= 400 \u0026\u0026 resp.StatusCode \u003c 500 {\n    decoder := json.NewDecoder(resp.Body)\n    errorResponse := \u0026messaging_api.ErrorResponse{}\n    if err := decoder.Decode(\u0026errorResponse); err != nil {\n        log.Fatal(\"failed to decode JSON: %w\", err)\n    }\n    log.Printf(\"status code: (%v), x-line-request-id: (%v), error response: (%v)\", resp.StatusCode, resp.Header.Get(\"x-line-request-id\"), errorResponse)\n}\n```\n\n## Help and media\n\nFAQ: https://developers.line.biz/en/faq/\n\nNews: https://developers.line.biz/en/news/\n\n\n## Versioning\n\nThis project respects semantic versioning.\n- See https://semver.org/\n\nHowever, if a feature that was publicly released is discontinued for business reasons and becomes completely unusable, we will release changes as a patch release.\n\n\n## Contributing\n\nPlease check [CONTRIBUTING](CONTRIBUTING.md) before making a contribution.\n\n\n## License\n\n```\nCopyright (C) 2016 LINE Corp.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fline%2Fline-bot-sdk-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fline%2Fline-bot-sdk-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fline%2Fline-bot-sdk-go/lists"}