property Client.api

Direct access to Telegram API methods

For every method see Telegram Bot API

Examples

Call method

import tgtb from "@izzqz/tgtb";

const bot_token = "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11";

const bot = tgtb(bot_token);

const res = await bot.api.sendMessage({
  chat_id: 123456,
  text: "Hello, world!"
});

if (res.ok) {
  console.log(res.result); // { message_id: 123456 }
} else {
  console.error(res.description); // "Bad Request: chat not found"
}

Get method URL

import tgtb from "@izzqz/tgtb";

const bot_token = "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11";

const url = tgtb(bot_token).api.getMe.url;
// https://api.telegram.org/bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11/getMe

Type

Usage

import { type Client } from ".";