LINE Things API reference

LINE Things API

note LINE Things not available on iOS v9.19.0 or later

Due to a technical issue, we've temporarily suspended LINE Things functionality on LINE for iOS v9.19.0 and later.

Specifying product ID to acquire PSDI by device ID

Specify the device ID, and acquire the product ID and PSDI. Used when acquiring the product ID and PSDI from the device ID acquired by the device link/unlink event.

For more information about the device ID, product ID, and PSDI, see IDs.

HTTP request

GET https://api.line.me/things/v1/devices/{deviceId}

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
deviceId Device ID

Example request

curl -X GET https://api.line.me/things/v1/devices/{deviceId} \
-H "Authorization: Bearer {channel access token}"

Response

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

Property Type Description
id String Device ID
productId String Product ID
productSpecificDeviceId String PSDI.

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:
  • Device not found.
  • There is no access permission.

Example response

{
  "id": "{deviceId}",
  "productId": "{productId}",
  "productSpecificDeviceId": "{PSDI}"
}

Acquiring device information by specifying product ID and user ID

Specify the product ID and user ID, and acquire the device information.

HTTP request

GET https://api.line.me/things/v1/products/{productId}/users/{userId}/links

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
productId Product ID
userId User ID. User ID value is a string matching the regular expression pattern U[0-9a-f]{32}.

Example request

curl -X GET https://api.line.me/things/v1/products/{productId}/users/{userId}/links \
-H "Authorization: Bearer {channel access token}"

Response

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

Property Type Description
items[].userId String User ID
User ID value is a string matching the regular expression pattern U[0-9a-f]{32}.
items[].device.id String Device ID
items[].device.productId String Product ID
items[].device.productSpecificDeviceId String PSDI.
items[].deviceDisplayName String Product name

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:
  • Device not found.
  • There is no access permission.

Example response

{
  "items": [
    {
      "userId": "{userId}",
      "device": {
        "id": "{deviceId}",
        "productId": "{productId}",
        "productSpecificDeviceId": "{PSDI}"
      },
      "deviceDisplayName": "{Product Name}"
    },
    {
      "userId": "{userId}",
      "device": {
        "id": "{deviceId}",
        "productId": "{productId}",
        "productSpecificDeviceId": "{PSDI}"
      },
      "deviceDisplayName": "{Product Name}"
    }
  ]
}

Creating trial product information

Create and register trial product information on the LINE Platform to ensure that Bluetooth® Low Energy-compatible devices can be used with the LINE Things Developer Trial. As a result of this operation, the trial product information and the Messaging API channel can be associated with each other.

Note: You can create a maximum of 10 trial product information items per channel.

HTTP request

POST https://api.line.me/things/v1/trial/products

Request headers

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

Request body

Field Type Description
name String Product name
liffId String LIFF app ID associated with the created trial product information

Example request

curl -X POST https://api.line.me/things/v1/trial/products \
-H "Authorization: Bearer {channel access token}" \
-H "Content-Type: application/json" \
-d '{
  "name": "{trial product name}",
  "liffId": "{LIFF APP ID}"
}'

Response

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

Property Type Description
id String Product ID
name String Product name
type String Product type (BLE only)
channelId Number Channel ID of the channel for Messaging API associated with the trial product information
actionUri String URL of the LIFF app
serviceUuid String Service UUID for service search *
This UUID is automatically numbered.
psdiServiceUuid String Service UUID for device identification*
psdiCharacteristicUuid String Characteristic UUID for device identification*

*These values are written to the device and LIFF app. For more information, see Creating devices and Finalizing the LIFF app.

Error response

One of the following status codes is returned.

Status code Description
400 The request contains an invalid value.
401 Authentication failed.
403 You've reached the maximum of 10 trial product information items. Delete the unnecessary trial product information items.

Example response

{
  "id": "{productId}",
  "name": "{trial product name}",
  "type": "BLE",
  "channelId": {channelId},
  "actionUri": "{LIFF APP URL}",
  "serviceUuid": "{serviceUuid}",
  "psdiServiceUuid": "{psdiServiceUuid}",
  "psdiCharacteristicUuid": "{psdiCharacteristicUuid}"
}

Acquiring trial product information

Acquire the created trial product information.

HTTP request

GET https://api.line.me/things/v1/trial/products

Request headers

Request header Description
Authorization Bearer {channel access token}

Example request

curl -X GET https://api.line.me/things/v1/trial/products \
-H "Authorization: Bearer {channel access token}"

Response

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

Property Type Description
[].id String Product ID
[].name String Product name
[].actionUri String URL of the LIFF app
[].channelId Number Channel ID of the channel for Messaging API associated with the trial product information
[].type String Product type ("BLE" only)
[].serviceUuid String Service UUID for service search
[].psdiServiceUuid String Service UUID for device identification
[].psdiCharacteristicUuid String Characteristic UUID for device identification

Error response

One of the following status codes is returned.

Status code Description
401 Authentication failed.

Example response

[
  {
    "id": "{productId}",
    "name": "{trial product name}",
    "actionUri": "{LIFF APP URL}",
    "channelId": {channelId},
    "type": "BLE",
    "serviceUuid": "{serviceUuid}",
    "psdiServiceUuid": "{psdiServiceUuid}",
    "psdiCharacteristicUuid": "{psdiCharacteristicUuid}"
  }
]

Deleting the trial product information

Specify the product ID, and delete the trial product information.

HTTP request

DELETE https://api.line.me/things/v1/trial/products/{productId}

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
productId Product ID

Response

Status code 204 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:
  • Trial product information not found.
  • There is no access permission.

Example request

curl -X DELETE https://api.line.me/things/v1/trial/products/{productId} \
-H "Authorization: Bearer {channel access token}"

Scenario management API for automatic communication

Create or update a scenario set

Register (create or update) a scenario set for automatic communication under a product.

HTTP request

PUT https://api.line.me/things/v1/products/{productId}/scenario-set

Request headers

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

Path parameters

Parameter Description
productId Product ID

Request body

Field Type Description
autoClose Boolean Specifies whether LINE should disconnect from the device after any scenario in the scenario set finishes running. If false, the connection is maintained. Pay careful attention to the values you use for these parameters. See also Important notes related to using automatic communication in the LINE Things documentation.
suppressionInterval Number If autoClose = true, this specifies the time (in milliseconds) before LINE should try to reconnect to the device after automatic disconnection. Reconnecting after the specified interval is not guaranteed to work. Depending on the environment in which LINE is running, the reconnection time may vary significantly. If
autoClose = false, set this to 0.
scenarios Array Array of scenario
Scenario
Field Type Description
id String Scenario ID
Not necessary when creating or updating a scenario set.
trigger Object Condition that, when met, starts the scenario.
trigger.type String
  • IMMEDIATE: Perform an action as soon as your device connects to the LINE app.
  • BLE_NOTIFICATION: Perform an action when receiving a notification with the specified GATT characteristic value.
trigger.serviceUuid String GATT service UUID (128 bit) that must be in notification. Set only for
trigger.type = BLE_NOTIFICATION.
trigger.characteristicUuid String GATT characteristic UUID (128 bit) that must be in notification. Set only for
trigger.type = BLE_NOTIFICATION.
actions[] Array Array of Actions
action may be empty if the scenario's only purpose is to retrieve notification data.
actions[].type String Action type
  • SLEEP: Wait for a specified period of time.
  • GATT_READ: Read data from the specified GATT characteristic value.
  • GATT_WRITE: Write data to the specified GATT characteristic value.
actions[].sleepMillis Number Time to spend in SLEEP
It is not guaranteed that SLEEP will end after the specified time. Depending on the environment in which LINE is running, the time may vary significantly.
Set this property only when actions[].type is SLEEP.
actions[].serviceUuid String GATT service UUID (128 bit) including GATT characteristic that reads and writes data
Set this property only when actions[].type is GATT_READ or GATT_WRITE.
actions[].characteristicUuid String GATT service characteristic (128 bit) that reads and writes data
Set this property only when actions[].type is GATT_READ or GATT_WRITE.
actions[].data String Base64 encoded data
Set this property only when actions[].type is GATT_WRITE.

Example request

curl -X PUT https://api.line.me/things/v1/products/{productId}/scenario-set \
-H "Authorization: Bearer {channel access token}" \
-H "Content-Type: application/json" \
-d '{
  "autoClose": false,
  "suppressionInterval": 0,
  "scenarios": [
    {
      "trigger": {
        "type": "BLE_NOTIFICATION",
        "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
        "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3"
      },
      "actions": [
        {
          "type": "SLEEP",
          "sleepMillis": 1000
        },
        {
          "type": "GATT_READ",
          "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
          "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3"
        },
        {
          "type": "GATT_WRITE",
          "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
          "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3",
          "data": "Zm9vCg=="
        }
      ]
    }
  ]
}'

Response

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

Property Type Description
productId String Product ID
autoClose Boolean Shows whether LINE will disconnect from the device after any scenario in the scenario set finishes running. If false, the connection is maintained. Think carefully about what value to specify for this property. See also Important notes related to using automatic communication in the LINE Things documentation.
suppressionInterval Number Specifies the time (in milliseconds) before LINE tries to reconnect with the device after automatic disconnection.
Reconnecting after the specified interval is not guaranteed to work. Depending on the environment in which LINE is running, the reconnection time may vary significantly.
revision Number Current revision of the scenario set. It is automatically incremented for each change.
scenarios Array Array of scenario
createdAt Number Date and time when the scenario set was created
updatedAt Number Date and time when the scenario set was updated

Error response

One of the following status codes is returned.

Status code Description
400 The request contains an invalid value.
401 Authentication failed.
404 This status code means one of the following:
  • Product information not found.
  • There is no access permission.

Example response

{
  "productId": "0",
  "autoClose": false,
  "suppressionInterval": 0,
  "revision": 123,
  "scenarios": [
    {
      "id": "01CGZVT9XTWA8Q2Z8QSX0B0EH8",
      "trigger": {
        "type": "BLE_NOTIFICATION",
        "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
        "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3"
      },
      "actions": [
        {
          "type": "SLEEP",
          "sleepMillis": 1000
        },
        {
          "type": "GATT_READ",
          "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
          "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3"
        },
        {
          "type": "GATT_WRITE",
          "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
          "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3",
          "data": "Zm9vCg=="
        }
      ]
    }
  ],
  "createdAt": "2018-04-12T23:20:50.52Z",
  "updatedAt": "2018-04-12T23:20:50.52Z"
}

Get a scenario set

Get the scenario set registered under a product.

HTTP request

GET https://api.line.me/things/v1/products/{productId}/scenario-set

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
productId Product ID

Example request

curl -X GET https://api.line.me/things/v1/products/{productId}/scenario-set \
-H "Authorization: Bearer {channel access token}"

Response

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

Property Type Description
productId String Product ID
autoClose Boolean Shows whether LINE will disconnect from the device after any scenario in the scenario set finishes running. If false, the connection is maintained. Think carefully about what value to specify for this property. See also Important notes related to using automatic communication in the LINE Things documentation.
suppressionInterval Number Specifies the time (in milliseconds) before LINE tries to reconnect with the device after automatic disconnection.
Reconnecting after the specified interval is not guaranteed to work. Depending on the environment in which LINE is running, the reconnection time may vary significantly.
revision Number Current revision of the scenario set. It is automatically incremented for each change.
scenarios Array Array of scenarios
createdAt Number Date and time when the scenario set was created
updatedAt Number Date and time when the scenario set was updated

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:
  • Product information not found.
  • There is no access permission.

Example response

{
  "productId": "0",
  "autoClose": false,
  "suppressionInterval": 0,
  "revision": 123,
  "scenarios": [
    {
      "id": "01CGZVT9XTWA8Q2Z8QSX0B0EH8",
      "trigger": {
        "type": "BLE_NOTIFICATION",
        "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
        "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3"
      },
      "actions": [
        {
          "type": "SLEEP",
          "sleepMillis": 1000
        },
        {
          "type": "GATT_READ",
          "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
          "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3"
        },
        {
          "type": "GATT_WRITE",
          "serviceUuid": "4812a0a6-10af-4afb-91f0-b4434e55763b",
          "characteristicUuid": "91a6fb1d-d365-4229-9d41-4358a96388e3",
          "data": "Zm9vCg=="
        }
      ]
    }
  ],
  "createdAt": "2018-04-12T23:20:50.52Z",
  "updatedAt": "2018-04-12T23:20:50.52Z"
}

Delete a scenario set

Delete a scenario set registered under a product.

HTTP request

DELETE https://api.line.me/things/v1/products/{productId}/scenario-set

Request headers

Request header Description
Authorization Bearer {channel access token}

Path parameters

Parameter Description
productId Product ID

Response

Status code 204 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:
  • Product information not found.
  • There is no access permission.

Example request

curl -X DELETE https://api.line.me/things/v1/products/{productId}/scenario-set \
-H "Authorization: Bearer {channel access token}"

{{ $t("form.question.helpful") }}

{{ $t("form.question.detail") }}

{{ $t("form.question.improve") }}

{{ $t("form.info.start") }}{{ $t("form.info.link") }}{{ $t("form.info.end") }}


{{ $t("form.result.success") }}
{{ $t("form.result.error") }}
{{ $t("form.result.errorLink") }}