Node.js wrapper for telegram-cli

Usage no npm install needed!

<script type="module">
  import tgNodeWrapper from '';



Node.js wrapper for telegram-cli


How to use

Install package from npm:

npm i tg-node-wrapper

Create config.js with:

const path = require('path');

module.exports = {
    telegram_cli_path: path.join(__dirname, 'tg/bin/telegram-cli'), //path to tg-cli (see
    telegram_cli_socket_path: path.join(__dirname, 'socket'), // path for socket file
    server_publickey_path: path.join(__dirname, 'tg/'), // path to server key (traditionally, in %tg_cli_path%/

Open your app script and use this example:

const TelegramAPI = require('tg-cli-node');
const config = require('./config');

const Client = new TelegramAPI(config);

Client.connect(connection => {
    connection.on('message', message => {
        console.log('message:', message);

    connection.on('error', e => {
        console.log('Error from Telegram API:', e);

    connection.on('disconnect', () => {
        console.log('Disconnected from Telegram API');