@effect-ak/tg-bot-client
Call any Bot API method with full type safety. Includes all types.
- execute() for every API method
- Automatic FormData for file uploads
- Typed errors and request timeouts
npm install @effect-ak/tg-bot-clientType-safe SDK for building Telegram bots — auto-generated types, lightweight client, zero runtime dependencies.
npm install @effect-ak/tg-bot-clientimport { makeTgBotClient } from "@effect-ak/tg-bot-client"
const client = makeTgBotClient({ bot_token: "YOUR_BOT_TOKEN"})
// full type safety for params and resultconst message = await client.execute("send_message", { chat_id: 123456, text: "Hello from the client!"})
console.log("Sent:", message.message_id)import { createBot } from "@effect-ak/tg-bot"
createBot() .onMessage(({ command, text }) => [ command("/start", ({ ctx }) => ctx.reply("Hello! I'm your new bot") ), text(({ ctx }) => ctx.reply(`You said: ${ctx.update.message.text}`) ) ]) .run({ bot_token: "YOUR_BOT_TOKEN" })import type { WebApp } from "@effect-ak/tg-bot-api"
declare const Telegram: { WebApp: WebApp }
const app = Telegram.WebAppapp.ready()
app.MainButton.setText("Submit")app.MainButton.onClick(() => { app.sendData(JSON.stringify({ action: "submit" }))})app.MainButton.show()Why this SDK
Three small packages that cover the whole Bot API surface — from raw types to a full bot runner.
400 types and 185 methods scraped from the official Telegram docs — regenerated on every Bot API release.
Every method knows its params and return type. Autocomplete in your editor instead of hopping to the docs.
Native fetch, no runtime deps. Runs on Node.js, Bun, Deno, and edge runtimes like Cloudflare Workers.
Develop locally with long polling, deploy to serverless with webhooks — same handlers, no code changes.
Discriminated unions instead of thrown surprises. Match on error tags and let the compiler check every branch.
Typed Telegram.WebApp API for building Mini Apps — buttons, haptics, themes, and more.
Examples
A full bot, a bare client call, or just the types — the API stays small at every layer.
Create a bot with command handling and text replies — no middleware, no boilerplate.
import { createBot } from "@effect-ak/tg-bot"
createBot() .onMessage(({ command, text }) => [ command("/start", ({ ctx }) => ctx.reply("Hello! I'm your new bot.") ), text(({ payload, ctx }) => ctx.reply(`You said: ${payload.text}`) ) ]) .run({ bot_token: "YOUR_BOT_TOKEN" })Install with npm install @effect-ak/tg-bot — includes the client and all types.
Call any Bot API method directly with full type safety and typed error handling.
import { makeTgBotClient } from "@effect-ak/tg-bot-client"
const client = makeTgBotClient({ bot_token: "YOUR_BOT_TOKEN"})
// throws TgBotClientError on failureconst message = await client.execute("send_message", { chat_id: 123456, text: "Hello from the client!"})
console.log("Sent:", message.message_id)
// or the non-throwing variantconst result = await client.executeSafe("get_me", {})
if (result.ok) console.log("Bot:", result.data.first_name)else console.log("Error:", result.error._tag)Install with npm install @effect-ak/tg-bot-client — lightweight client without the bot runner.
Use auto-generated TypeScript types for the Telegram.WebApp API in your Mini App.
import type { WebApp } from "@effect-ak/tg-bot-api"
declare const Telegram: { WebApp: WebApp }
const app = Telegram.WebAppapp.ready()
app.MainButton.setText("Submit")app.MainButton.onClick(() => { app.sendData(JSON.stringify({ action: "submit" }))})app.MainButton.show()Install with npm install @effect-ak/tg-bot-api — types only, zero runtime code.
Packages
Take just the client, the whole framework, or only the types — each package builds on the one below it.
Call any Bot API method with full type safety. Includes all types.
npm install @effect-ak/tg-bot-clientFluent builder API, long polling, and webhooks. Includes the client and all types.
npm install @effect-ak/tg-botPure TypeScript types for the Bot API and Mini Apps. Zero runtime code.
npm install @effect-ak/tg-bot-apiInstall the SDK, paste a token from BotFather, and your bot is live — or try it right in the browser first.
Open source and free forever — star it on GitHub