LINE API Command Line Interface

mick

Satana Charuwichitratana

Posted on January 23, 2020

LINE API Command Line Interface

LINE API CLI helps you to work with LINE-API-related projects faster as you do not need to switch between a web browser and IDE ( after your first-time setup :P ). If you already are a hardcore "Terminal/Console" fanboy that using cURL to work with LINE APIs, using this package will reduce your time typing same long API cURL commands.

Available commands, operations, and options

LINE API configuration and token management

  • line
    • init
    • token
      • --issue
      • --revoke

Richmenu API

  • richmenu
    • add
    • remove
    • list
    • default
    • link
    • unlink

LIFF API v1

  • liff
    • add
    • remove
    • update
    • list

LINE Things API

  • things
    • add:trial
    • remove:trial
    • list:trial
    • get:device
    • get:devices
    • get:product

Scenario management API for automatic communication

  • things
    • register:scenario-set
    • remove:scenario-set
    • get:scenario-set

LINE TV API

  • linetv
    • list:modules
    • get:spotlight
    • list:category
    • get:category
    • list:station
    • get:station
    • ranking
    • search
    • live

Installation

npm i @intocode-io/line-api-cli -g

npm i @intocode-io/line-api-cli -g

Project setup with line command

Let's start, to initialize project configuration file. Please go to your LINE Developer Console and get Channel ID and Channel secret. If you do not want to issue a short-lived access token later on, you will also need a long-lived access token.

Once you have the information, run line command with init operation.

line init

This command will create .line-api-cli.yml configuration file containing necessary information for the CLI to handle API request/response for you.

line init

Issue a short-lived access token

Long-lived access token is nice and easy to use for developers but it is not as secured as a short-lived access token.

To issue a short-lived access token, run the following command.

line token --issue

It will issue a short-lived access token. You can choose whether to replace the token into .line-api-cli.yml

line token --issue

Do not forget to replace a short-lived. It is recommended to write a script to replace the token monthly.

Revoke access token

Ok, sometime you may feel insecure after exposing access token somewhere. No problem, you can revoke it with --revoke option.

line token --revoke

Working with richmenu command

It's time to display nice UI menu to your users, or maybe some menu to some specific user(s). You can do those tasks with richmenu command.

Add a rich menu

First you need to prepare a data file and an image file for rich menu. After you have those in your project directory, you can run richmenu command with add operation to add a rich menu.

richmenu add

richmenu add

List rich menus

Rich menus can be listed with list operation.

richmenu list

richmenu list

Remove a rich menu

Get bored of old rich menu? You can remove a rich menu with remove operation.

richmenu remove

Then choose a rich menu to be removed.

richmenu remove

Set a rich menu as default

If you'd like to set a rich menu as default for all users, run the following command.

richmenu default

Link a rich menu to a user

Rich menu can be linked to a specific user. For example, if you want a rich menu assigned only to LINE user with Administrator role. You can get a user ID and link a rich menu for the user with this command.

richmenu link

Unlink a rich menu from a user

Rich menu can be unlinked from a specific user using unlink operation.

richmenu unlink

Working with LIFF app using liff command

To develop more advanced LINE Bot, LIFF app may required. You can use liff command to manage LIFF apps.

Add a LIFF app

liff add

liff add

List LIFF apps

liff list

Remove a LIFF app

liff remove

Update a LIFF app

liff update

Working with LINE Things using things command

List all LINE Things trial products

things list:trial

Add a trial product

things add:trial

Remove a trial product

things remove:trial

Get device information by device ID and user ID

things get:device

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

things get:devices

Specify the device ID, and acquire the product ID and PSDI

things get:product

Scenario management API for automatic communication

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

things register:scenario-set

Get the scenario set registered under a product

things get:scenario-set

Delete a scenario set registered under a product

things remove:scenario-set

Working with LINE TV using linetv command

List sportlight curation module types

linetv list:modules

To get sportlight curation module types in JSON use --format option.

linetv list:modules --format json

Get sportlight data

linetv get:spotlight

To get sportlight data in JSON use --format option.

linetv get:sportlight --format json

Category List

linetv list:category

To get category list in JSON use --format option.

linetv get:sportlight --format json

Gets category home data

linetv get:category

To get category home data in JSON use --format option.

linetv get:category --format json

To get category home data start from selected page use --page option.

linetv get:station --page <number>

Gets clip ranking data

linetv ranking

To get clip ranking data in JSON use --format option.

linetv ranking --format json

To get clip ranking data start from selected page use --page option.

linetv ranking --page <number>

Gets a clip search result

linetv search

To get clip search result in JSON use --format option.

linetv search --format json

To get clip search result from selected page use --page option.

linetv search --page <number>

Gets the station home (TV station) list.

linetv list:station

To get station home (TV station) list in JSON use --format option.

linetv list:station --format json

Gets the Station Home (TV Station) data.

linetv get:station

To get TV Station data in JSON use --format option.

linetv get:station --format json

To get TV Station data start from selected page use --page option.

linetv get:station --page <number>

Gets live schedule information.

linetv live

To get live schedule data in JSON use --format option.

linetv live --format json

Comprehensive usage

We provide comprehensive usage of each command / operation / option with CLI. Simply run a command with/without operation and follow by --help option. For example,

line token --help

Or

line --help

line --help

💖 💪 🙅 🚩
mick
Satana Charuwichitratana

Posted on January 23, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

LINE API Command Line Interface
line LINE API Command Line Interface

January 23, 2020