npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xalbex/telegram-bot

v0.0.4

Published

Telegram Bot API for Node.js

Readme

Telegram Bot API for Node.js

This is a Node.js module to communicate with official Telegram Bot API. To use this module the bot token is required and can be obtained by talking to @botfather.

Why use this module insead compared to others?

  • It has no dependencies. It reduce the size of your project.

  • It is written in Typescript and contains the definitions of all official methods and structures useful for type checking. This means that the editor can suggest you errors, name and the official documentation for each member.

  • It can be used without or with a little abstraction. This allows you to finely control your bot without being limited by this module.

  • For all the requests it return a Promise, this simplify the asynchronous procedures.

How to install

Go in your project folder and run the following command:

$ npm install --save @xalbex/telegram-bot

How to use

This module exports different object to do the same things:

  • Raw (only official methods)
  • Emitter (official methods + emitting an event for each new update)

Raw

It provide all the official methods without any abstraction. All methods accept the same parameters specified in the Telegram Bot API documentation and return a Promise with the result specified in the official documentation.

import * as TelegramBot from 'telegram-bot-js'

// Replace the value below with the Telegram token you receive from @BotFather
const token = '<BOT-TOKEN>';

// Create an object that manages the Telegram bot and receives the updates.
const bot = new TelegramBot.Raw (token);

// Send the message to a specific chat
let promise = bot.sendMessage ({ chat_id: '<A chat id>', text: 'Hello world!' });

Emitter

It simplifies the management of updates. It is a EventEmitter and is possible to add listners. The events emitted have the same names of the update types specified in the Update object in the documentation: message, edited_message, channel_post, ...

It contains a member api that is the raw client discussed above.

import * as TelegramBot from 'telegram-bot-js'

// Replace the value below with the Telegram token you receive from @BotFather
const token = '<BOT-TOKEN>';

// Create an object that manages the Telegram bot and receives the updates.
const bot = new TelegramBot.Emitter (token);

// Listen for message events. The list of possible events is specified 
// here (https://core.telegram.org/bots/api#update)
bot.on ('message', async msg => 
{
   // Send a message to the chat acknowledging receipt of their message
   let result = await bot.api.sendMessage ({ chat_id: msg.chat.id, text: 'Hi!' });

   // Write the server response to the terminal
   console.log (result);
});