Registry / communication / messaging-api-line

messaging-api-line

JSON →
library1.1.0jsnpmunverified

A Node.js client library for the LINE Messaging API, version 1.1.0. Maintained as part of the Yoctol messaging-apis monorepo, it provides a comprehensive, TypeScript-first wrapper for LINE's REST endpoints including reply, push, multicast, broadcast, and rich menu APIs. The library uses axios for HTTP and wraps errors for better debugging. Key differentiators: full TypeScript types, camelCase key support (v1.0.0+), factory methods for message creation, and support for Flex and Imagemap messages. Release cadence is sporadic with the last release in October 2021.

npm install messaging-api-line
INSTALL
IMPORT
SIG · MESSAGING-API-LINE
M
messaging-api-line
communicationjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LineClient
import { LineClient } from 'messaging-api-line'
import LineClient from 'messaging-api-line'
Named export only; no default export. CommonJS: const { LineClient } = require('messaging-api-line')
Line
import { Line } from 'messaging-api-line'
import Line from 'messaging-api-line'
Namespace object with factory methods (createText, etc.). Not a class. ESM only.
LineClientConfig
import { LineClientConfig } from 'messaging-api-line'
TypeScript type for client config. Also importable as type: import type { LineClientConfig } from 'messaging-api-line'

Initializes LineClient with credentials, then demonstrates reply, push, broadcast, and getBotInfo APIs.

import { LineClient } from 'messaging-api-line'; const client = new LineClient({ accessToken: process.env.LINE_ACCESS_TOKEN ?? '', channelSecret: process.env.LINE_CHANNEL_SECRET ?? '', }); // Reply to a webhook event await client.reply(REPLY_TOKEN, [ { type: 'text', text: 'Hello from messaging-api-line!', }, ]); // Push a message to a user await client.push(USER_ID, [ { type: 'text', text: 'This is a push message.', }, ]); // Broadcast to all friends await client.broadcast([ { type: 'text', text: 'Broadcast message', }, ]); // Get bot info const botInfo = await client.getBotInfo(); console.log(botInfo);
Debug
Known issues
breakingv1.0.0 switched from snake_case to camelCase keys. Old code using snake_case will break.
fix
Update all API parameters and message objects to use camelCase keys (e.g., replyToken → replyToken, originalContentUrl → originalContentUrl).
affects: <1.0.0
breakingv1.0.0 removed namespace exports. Use 'messaging-api-line' directly instead of 'messaging-api-line/dist/...'.
fix
Change imports from 'messaging-api-line/dist/LineClient' to 'messaging-api-line'.
affects: <1.0.0
gotchaThe replyToken can only be used once. Attempting to reply twice with the same token will result in an error.
fix
Track used tokens and only reply once per webhook event.
affects: >=0.0.0
deprecatedOlder versions used snake_case for message types (e.g., 'imagemapMessage'). Version 1.1.0 prefers camelCase for fields but still accepts snake_case for compatibility? Not explicitly deprecated but caution advised.
fix
Always use camelCase keys for message fields to ensure compatibility with future versions.
affects: >=1.0.0
Errors
Common errors & fixes
Error: replyToken is required
Calling client.reply() without a reply token or with an undefined/null token.
fix
Provide a valid replyToken from the webhook event (e.g., req.body.events[0].replyToken). Ensure environment variable is set.
TypeError: Cannot read properties of undefined (reading 'config')
Missing or invalid accessToken/channelSecret in client constructor.
fix
Verify LINE_ACCESS_TOKEN and LINE_CHANNEL_SECRET are set and passed correctly.
Error: Request failed with status code 401
Invalid or expired access token.
fix
Regenerate access token from LINE Developers console and update your code.
TypeError: client.broadcast is not a function
Using an older version (<1.1.0) that does not support broadcast API.
fix
Upgrade to messaging-api-line@1.1.0 or later. npm install messaging-api-line@latest
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
axiosrequiredHTTP client for all API requests
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
messaging-api-line — npm install messaging-api-line · libregistry