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

@snakebot/telegram

v0.1.3

Published

telegram bot api wrapper

Readme

Node.js Telegram API Wrapper

This is a simple Node.js wrapper for the Telegram Bot API. It provides a convenient way to interact with Telegram Bots by abstracting away the low-level details of the Telegram Bot API.

Installation

To install this package, run the following command:

npm install @snakebot/telegram

Usage

Initialization

First, require the package in your code:

const telegramApi = require('@snakebot/telegram');

classes

  • botapi

Configuration

To configure the API, call the configure() method and pass in the configuration object:

telegramApi.botapi.configure({
    bot: {
        api : "https://api.telegram.org",
        token: "<YOUR_BOT_TOKEN>",
        longPoll: false,
        longPollingTimeout: 30
    }
});

Methods

getMe(callback)

Gets information about the bot.

telegramApi.botapi.getChat((data) => {
    console.log(data);
}, chat_id);

getChat(callback, chat_id)

Gets information about a chat.

telegramApi.botapi.getChat((data) => {
    console.log(data);
}, chat_id);

sendMessage( callback, chat_id, text, disable_notification, protect_content, reply_to_message_id, allow_sending_without_reply, parse_mode, entities, disable_web_page_preview, reply_markup)

Use this method to send text messages. On success, the sent Message is returned.

telegramApi.botapi.sendMessage((result)=>{
    if(result.err){
        console.log(err.message)
    } else {
        console.log(result)
    }
}, 
    320794723, 
    "sorry, bot is not yet ready",
    true,)

close(callback)

Use this method to close the bot instance before moving it from one local server to another. You need to delete the webhook before calling this method to ensure that the bot isn't launched again after server restart. The method will return error 429 in the first 10 minutes after the bot is launched. Returns True on success. Requires no parameters

telegramApi.botapi.close((data) => {
    console.log(data);
});

logout(callback)

Use this method to log out from the cloud Bot API server before launching the bot locally. You must log out the bot before running it locally, otherwise there is no guarantee that the bot will receive updates. After a successful call, you can immediately log in on a local server, but will not be able to log in back to the cloud Bot API server for 10 minutes. Returns True on success. Requires no parameters.

telegramApi.botapi.logout((data) => {
    console.log(data);
});

getUpdatePolling(callback, offset, timeout)

Polls for updates from Telegram.

telegramApi.botapi.getUpdatePolling((data) => {
    console.log(data);
}, offset, timeout);

getWebhookInfo(callback)

Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.

telegramApi.botapi.getWebhookInfo((data) => {
    console.log(data)
})

deleteWebhook(callback, drop_pending_updates)

Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.

telegramApi.botapi.deleteWebhook((data) => {
    console.log(data)
})

setWebhook(callback, url, certificate, ip_address, max_connections, allowed_updates)

Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success.

If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content

telegramApi.botapi.setWebhook((data) => {
    console.log(data)
}, 'http://example.com/bot')

License

Apache-2.0