LIFF API reference

Client API

LIFF SDK errors

LIFF SDK errors are returned in LIFF error objects.

LIFF error object

Property Type Description
code String Code
message String Message. This property is returned if a defined message exists.

Error details

Code Message Description
INIT_FAILED Failed to init LIFF SDK Could not load JavaScript resource of the SDK.
INIT_FAILED Current environment is not supported. Please open it with LINE Attempted to open the LIFF app in the unsupported environment.
INVALID_ARGUMENT - Arguments are invalid.
INTERNAL_ERROR - An internal error occurred.

Example error

{
  "code":"INIT_FAILED",
  "message":"Failed to init LIFF SDK"
}

liff.init()

Initializes a LIFF app. This method will allow you to execute the other methods of the LIFF SDK.

Syntax

liff.init(successCallback, errorCallback)

Arguments

Property Type Required Description
successCallback Function Required Callback to return a data object upon a successful call
errorCallback Function Required Callback to return an error object upon a failed call

Example request

// No sample code available
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
liff.init(
  data => {
    // Now you can call LIFF API
    const userId = data.context.userId;
  },
  err => {
    // LIFF initialization failed
  }
);

Return value

Returns a data object that contains the information necessary to make various API calls.

Data object
Property Type Description
language String Language setting of LINE
context.type String Type of context. This property indicates where the LIFF app was opened within LINE. One of the following values is contained:
  • utou: One-on-one chat
  • room: Room
  • group: Group
  • none: Not in a chat screen
context.viewType String Size of the LIFF app view. One of the following values is contained:
  • compact
  • tall
  • full
For more information, see Add LIFF app.
context.userId String User ID. This property is included when the context.type property has a value other than none.
context.utouId String One-on-one chat ID. This property is included when the context.type property has a value of utou.
context.roomId String Room ID. This property is included when the context.type property has a value of room.
context.groupId String Group ID. This property is included when the context.type property has a value of group.

Example return value

{
  "language":"ja-JP",
  "context":{
    "userId":"U4af498...",
    "type":"group",
    "groupId":"Ca5637c...",
    "viewType":"full"
  }
}

liff.openWindow()

Opens the specified URL in the in-app browser of LINE or external browser.

Syntax

liff.openWindow(params)

Arguments

params object
Property Type Required Description
url String Required URL. Specify the absolute path to the URL.
external Boolean Optional Whether to open the URL in an external browser. Specify one of the following values: The default value is false.
  • true: Opens the URL in an external browser.
  • false: Opens the URL in the in-app browser of LINE.

Return value

None

Example request

// No sample code available
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
liff.openWindow({
  url:'https://example.com',
  external:true
});

liff.getProfile()

Gets the current user's profile.

Syntax

liff.getProfile()

Arguments

None

Example request

// No sample code available
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
liff.getProfile()
.then(profile => {
  const name = profile.displayName
})
.catch((err) => {
  console.log('error', err);
});

Return value

Returns a Promise object that contains the user's profile information.

Property Type Description
userId String User ID
displayName String Display name
pictureUrl String Image URL. This property is not returned if it has not been set by the user.
statusMessage String Status message. This property is not returned if it has not been set by the user.

This method internally calls the Social API using axios. For error handling, refer to the axios documentation and Status codes in the Social API reference documentation.

Example return value

{
  "userId":"U4af4980629...",
  "displayName":"Brown",
  "pictureUrl":"https://example.com/abcdefghijklmn",
  "statusMessage":"Hello, LINE!"
}

liff.sendMessages()

Sends messages on behalf of the user to the chat screen where the LIFF app is opened.

Syntax

liff.sendMessages(messages)

Arguments

Property Type Required Description
messages Array of objects Required Message objects
Max: 5
You can send the following types of Messaging API messages:

When messages are sent to a chat that a bot is in, the LINE Platform sends webhook events to the bot channel. When image, video, and audio messages are sent using the liff.sendMessages() method, resulting webhook events contain the contentProvider.type property whose value is external. For more information, see Message event in the Messaging API reference.

Return value

There is no return value if the message is sent successfully.

This method internally calls the Social API using axios. For error handling, refer to the axios documentation and Status codes below.

Status codes
Status code Description
400 The message is invalid.
401 Authentication failed.
403 The access token does not have appropriate permissions.

Example request

// No sample code available
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
liff.sendMessages([
  {
    type:'text',
    text:'Hello, World!'
  }
])
.then(() => {
  console.log('message sent');
})
.catch((err) => {
  console.log('error', err);
});

liff.closeWindow()

Closes the LIFF app.

Syntax

liff.closeWindow()

Arguments

None

Return value

None

Example request

// No sample code available
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
liff.closeWindow();

Server API

Add LIFF app

Adds an app to LIFF. You can add up to 30 LIFF apps on one channel.

HTTP request

POST https://api.line.me/liff/v1/apps

Request headers

Request header Description
Authorization Bearer {channel access token}
Content-Type application/json

Request body

Property Type Required Description
view.type String Required Size of the LIFF app view. Specify one of the following values:
  • compact: 50% of the screen height of the device.
  • tall: 80% of the screen height of the device.
  • full: 100% of the screen height of the device.
view.url String Required URL of the LIFF app. The URL scheme must be https.
description String Optional Name of the LIFF app.
features.ble Boolean Optional true if the LIFF app supports Bluetooth® Low Energy (BLE). false otherwise.

Example request

curl -X POST https://api.line.me/liff/v1/apps \
-H "Authorization: Bearer {channel access token}" \
-H "Content-Type: application/json" \
-d '{
  "view":{
    "type":"full",
    "url":"https://example.com/myservice"
  },
  "description": "Service Example",
  "features": {
    "ble": true
  }
}'
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
// No sample code available

Response

Returns the status code 200 and a JSON object with the following properties.

Property Type Description
liffId String LIFF app ID

Error response

One of the following status codes is returned.

Status code Description
400 This status code means one of the following:
  • The request contains an invalid value.
  • The maximum number of LIFF apps that can be added to the channel has been reached.
401 Authentication failed.

Example response

{
  "liffId":"{liffId}"
}

Update LIFF app

Partially updates LIFF app settings.

HTTP request

PUT https://api.line.me/liff/v1/apps/{liffId}

Request headers

Request header Description
Authorization Bearer {channel access token}
Content-Type application/json

Path parameters

Parameter Description
liffId ID of the LIFF app to be updated

Request body

Property Type Required Description
view.type String Optional Size of the LIFF app view. Specify one of the following values:
  • compact: 50% of the screen height of the device.
  • tall: 80% of the screen height of the device.
  • full: 100% of the screen height of the device.
view.url String Optional URL of the LIFF app. The URL scheme must be https.
description String Optional Name of the LIFF app.
features.ble Boolean Optional true if the LIFF app supports Bluetooth® Low Energy (BLE). false otherwise.

Note: Only the properties specified in the request body are updated.

Response

Status code 200 is returned.

Error response

One of the following status codes is returned.

Status code Description
401 Authentication failed.
404 This status code means one of the following:
  • The specified LIFF app does not exist.
  • The specified LIFF app belongs to another channel.

Example request

curl -X PUT https://api.line.me/liff/v1/apps/{liffId} \
-H "Authorization: Bearer {channel access token}" \
-H "Content-Type: application/json" \
-d '{
  "view": {
    "url":"https://new.example.com"
  }
}'
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
// No sample code available

Get all LIFF apps

Gets information on all the LIFF apps registered in the channel.

HTTP request

GET https://api.line.me/liff/v1/apps

Request headers

Request header Description
Authorization Bearer {channel access token}

Example request

curl -X GET https://api.line.me/liff/v1/apps \
-H "Authorization: Bearer {channel access token}"
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
// No sample code available

Response

Returns the status code 200 and a JSON object with the following properties.

Property Type Description
apps Array of objects Array of LIFF app objects

LIFF app object
Property Type Description
liffId String LIFF app ID
view.type String Size of the LIFF app view. One of the following values is contained:
  • compact: 50% of the screen height of the device.
  • tall: 80% of the screen height of the device.
  • full: 100% of the screen height of the device.
view.url String URL of the LIFF app
description String Name of the LIFF app
features.ble Boolean true if the LIFF app supports Bluetooth® Low Energy (BLE)

Error response

One of the following status codes is returned.

Status code Description
401 Authentication failed.
404 There is no LIFF app on the channel.

Example response

{
  "apps":[
    {
      "liffId":"{liffId}",
      "view":{
        "type":"full",
        "url":"https://example.com/myservice"
      },
      "description": "Happy New York"
    },
    {
      "liffId":"{liffId}",
      "view":{
        "type":"tall",
        "url":"https://example.com/myservice2"
      },
      "features": {
        "ble": true
      }
    }
  ]
}

Delete LIFF app

Deletes a LIFF app.

HTTP request

DELETE https://api.line.me/liff/v1/apps/{liffId}

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
liffId ID of the LIFF app to be deleted

Response

Status code 200 is returned.

Error response

One of the following status codes is returned.

Status code Description
401 Authentication failed.
404 This status code means one of the following:
  • The specified LIFF app does not exist.
  • The specified LIFF app belongs to another channel.

Example request

curl -X DELETE https://api.line.me/liff/v1/apps/{liffId} \
-H "Authorization: Bearer {channel access token}"
// No sample code available
# No sample code available
// No sample code available
// No sample code available
# No sample code available
# No sample code available
// No sample code available