@effect-ak/tg-bot-api

中文文档
1.13.0发布于 2026/11/13MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2974

TypeScript types for Telegram Bot Api and Telegram Mini Apps

原始使用文档
文档目录13 节
  1. Installation
  2. Features
  3. What's Exported
  4. Documentation
  5. Updating Telegram Bot API Types
  6. Project context
  7. 1. Delete cached HTML
  8. 2. Run codegen
  9. 3. Check what changed
  10. 4. Analyze the changelog
  11. 5. Verify everything works
  12. 6. Report
  13. License

@effect-ak/tg-bot-api

NPM Version Telegram Bot API Telegram WebApp

Complete TypeScript types for Telegram Bot API and Mini Apps, auto-generated from official documentation.

Installation

npm install @effect-ak/tg-bot-api

Features

  • Always Up-to-Date — generated from official Telegram docs via code generator
  • WebApp Types — types for Telegram.WebApp included
  • Smart Type Mapping — Integer → number, True → boolean, enums → union literals, etc.

What's Exported

import type {
  Api,
  Update,
  Message,
  CallbackQuery,
  InlineKeyboardMarkup,
  SendMessageInput,
  WebApp
} from "@effect-ak/tg-bot-api"

// Api — one method per Bot API method, snake_case, typed input → typed result
interface Api {
  send_message(_: SendMessageInput): Message
  answer_callback_query(_: AnswerCallbackQueryInput): boolean
  // … every Bot API method
}
// Every Bot API type as an interface (Update, Message, Chat, User, …)
// <Method>Input — parameter object of each method (SendMessageInput, EditMessageTextInput, …)
// WebApp, WebAppInitData, ThemeParams, … — Telegram.WebApp (Mini Apps) surface
// verifyLoginData(...) — validate Telegram Login Widget / Mini App init data hash

Field names, optionality and descriptions are taken verbatim from the official docs, so anything you read at https://core.telegram.org/bots/api applies as is. InputFile parameters additionally accept { file_content: Uint8Array, file_name: string } (used by the client for uploads).

Machine-readable versions of the same spec are published with the docs: bot-api.json, mini-app.json.

Documentation

Updating Telegram Bot API Types

Use this checklist when a new Telegram Bot API version is released.

Project context

  • Monorepo with pnpm workspaces.
  • packages/api/ contains auto-generated TypeScript types from official Telegram Bot API HTML docs.
  • Codegen scrapes https://core.telegram.org/bots/api and https://core.telegram.org/bots/webapps.
  • Downloaded HTML is cached in packages/api/input/api.html and packages/api/input/webapp.html.
  • Version files are packages/api/bot-api-version.json and packages/api/mini-app-version.json.
  • Stats are stored in docs/src/data/bot-api-stats.json.
  • Badges are updated in readme.md and packages/api/readme.md.

1. Delete cached HTML

Remove both cached files so codegen downloads fresh docs:

rm -f packages/api/input/api.html packages/api/input/webapp.html

2. Run codegen

cd packages/api && pnpm run gen

This will:

  • Download fresh HTML from Telegram.
  • Parse and generate TypeScript types into src/specification/.
  • Update version files and stats automatically.

3. Check what changed

git diff --stat

Look at:

  • packages/api/bot-api-version.json - did the version number change?
  • packages/api/src/specification/types.ts - new or changed interfaces.
  • packages/api/src/specification/api.ts - new or changed methods.
  • docs/src/data/bot-api-stats.json - updated type and method counts.

4. Analyze the changelog

Read packages/api/input/api.html and search for the changelog section near the top. Look for the latest version entry and summarize:

  • New types added.
  • New methods added.
  • New or changed fields on existing types.
  • Any breaking changes, such as removed or renamed fields.

5. Verify everything works

Run in sequence:

pnpm build
pnpm typecheck
pnpm test

All commands must pass with zero errors.

6. Report

Output a summary with:

  • Previous version -> new version.
  • Number of new types and methods.
  • Key changes, including new types, methods, and fields.
  • Build, typecheck, and test status.
  • Reminder to create a changeset. A minor changeset on @effect-ak/tg-bot-api is enough because fixed versioning in .changeset/config.json will bump all three packages together.

License

MIT

版本与发布记录

@effect-ak/tg-bot-api 共发布 17 个版本,首次发布于 2025/12/08;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.13.0latest2026/11/13今天
1.12.02026/09/052 个月前
1.11.02026/08/262 个月前
1.10.02026/08/152 个月前
1.9.02026/07/173 个月前
1.8.02026/07/084 个月前

关于 @effect-ak/tg-bot-api 的常见问题

@effect-ak/tg-bot-api 是什么?

TypeScript types for Telegram Bot Api and Telegram Mini Apps

如何安装 @effect-ak/tg-bot-api?

在项目目录运行 npm install @effect-ak/tg-bot-api,或使用 pnpm add / yarn add / bun add。

@effect-ak/tg-bot-api 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@effect-ak/tg-bot-api 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@effect-ak/tg-bot-api 可以商用吗?

@effect-ak/tg-bot-api 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@effect-ak/tg-bot-api 的下载量有多少?

根据 npm 官方下载统计,@effect-ak/tg-bot-api 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,974 次,日均约 99 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@effect-ak/tg-bot-api 还在维护吗?

最新版本 1.13.0 发布于 2026/11/13(今天);至今共发布 17 个版本,其中过去 12 个月发布了 17 个;首次发布于 2025/12/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。