| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| README.md | 2026-06-12 | 6.4 kB | |
| v1.0.0 source code.tar.gz | 2026-06-12 | 1.3 MB | |
| v1.0.0 source code.zip | 2026-06-12 | 1.3 MB | |
| Totals: 3 Items | 2.6 MB | 0 | |
Rewritten in TypeScript
The library has been rewritten from JavaScript to TypeScript and now requires
Node.js ≥ 18. The public surface — the TelegramBot class, its method
names, their positional arguments, and the emitted events — is otherwise
unchanged, so most bots keep working after the breaking changes below.
Migrating from v0.67.x
- ESM-only. The package is
"type": "module";require()no longer works — useimport TelegramBot from "node-telegram-bot-api". The class is both the default and a named export. If you are stuck on CommonJS, load it with a dynamic import:const { default: TelegramBot } = await import("node-telegram-bot-api"). answerCallbackQuery— the legacyanswerCallbackQuery(id, text, showAlert)andanswerCallbackQuery([options])forms are removed; useanswerCallbackQuery(id, { text, show_alert }).thumb→thumbnailonsendAudio/sendDocument/sendVideo/sendAnimation/sendVoiceand the sticker methods.reply_to_message_id→reply_parameters:{ reply_parameters: { message_id } }.- Reply-keyboard string shorthand removed.
KeyboardButtonis an object only; usekeyboard: [[{ text: "Yes" }]]instead ofkeyboard: [["Yes"]]. (reply_markupis still serialized for you, or you may pass a pre-stringified value.) - Error
responseshape. Errors still exposecode(EFATAL/EPARSE/ETELEGRAM) andresponse, butresponseis now a plain object, not the rawhttp.IncomingMessage: readerror.response.status(wasresponse.statusCode);error.response.bodyis unchanged. NTBA_FIX_350removed.filename/contentTypeare always auto-resolved (including magic-byte sniffing ofBuffers); override per call via the file-options argument.requestconstructor option still exists but feeds the internalfetch-basedHttpClient(timeouts, default headers) rather than the oldrequestlibrary — review any proxy/agent configuration.- Build output moved from
lib/todist/.
Breaking changes for @types/node-telegram-bot-api users
The bundled types replace the community @types/node-telegram-bot-api
(DefinitelyTyped) package. Uninstall @types/node-telegram-bot-api; the
following differences affect existing typed code:
- Types are no longer namespaced. The old package exposed everything under a
TelegramBot.*namespace (TelegramBot.Message,TelegramBot.ChatId, …). Types are now flat named exports — replaceTelegramBot.Messagewith a named import:import TelegramBot, { type Message } from "node-telegram-bot-api". The default import of the class is unchanged. *Optionsinterfaces are now*Paramstypes. Per-method option interfaces (SendMessageOptions,SendPhotoOptions, …) are replaced by docs-faithful<Method>Paramstypes that include the positional arguments; each method types its trailing argument asOmit<<Method>Params, …>. There are no aliases under the old names.- Renamed types:
ConstructorOptions→TelegramBotOptions,StartPollingOptions→PollingStartOptions,StopPollingOptions→PollingStopOptions,FileOptions→FileMeta,Metadata→EventMetadata,TelegramEvents→TelegramBotEvents.TextListener/ReplyListenerare no longer exported. restrictChatMember(chatId, userId, permissions, options?)—permissionsis now a required positional argument, not an option field.sendPoll—pollOptionschanged fromstring[]toInputPollOption[]({ text, … }objects), matching the current Bot API.setStickerSetThumb→setStickerSetThumbnail(method renamed; adds aformatoption).- Removed legacy option fields (the generated params are docs-faithful):
disable_web_page_preview(uselink_preview_options), top-levelallow_sending_without_reply(usereply_parameters), andanswerInlineQuery'sswitch_pm_text/switch_pm_parameter(usebutton). - Constructor
requestoption is no longer therequestlibrary'sOptionstype — the client isfetch-based and the dependency is dropped. PollingOptions.intervalisnumberonly (wasstring | number).- Array arguments (
answerInlineQueryresults,sendMediaGroupmedia,sendInvoiceprices,setMyCommandscommands) no longer acceptreadonlyarrays.
Added
- TypeScript — full type coverage for all API methods, options, and responses, bundled with the package (no separate
@types/...install) - Generated types —
src/types/schemas.tsis generated from the live Bot API docs (npm run generate:types) as plaintypealiases; the types are docs-faithful and carry no runtime validation - ESM — the package is now ESM-only (
"type": "module");require()is no longer supported TelegramBotOptionstype exported from the main entrypoint- Type exports:
ChatId,ParseMode,MessageEntity,ReplyMarkup,ReplyParameters,LinkPreviewOptions,SuggestedPostPrice,SuggestedPostInfo,SuggestedPostParameters, and all generated API types - Node.js native test runner replaces Mocha
sendLivePhotomethod
Changed
src/telegram.js→src/telegram.ts(full rewrite)src/telegramPolling.js→src/polling.tssrc/telegramWebHook.js→src/webhook.tssrc/errors.js→src/errors.tssrc/utils.js→src/utils.tstest/rewritten in TypeScript withnode:testassertions- Build output:
lib/→dist/
Removed
- CJS support —
require('node-telegram-bot-api')no longer works; useimport - Mocha test infrastructure (
test/mocha.opts, legacytest/telegram.js) - Legacy
lib/output directory - Legacy file-option param
thumb— replaced bythumbnail - Deprecated request option
reply_to_message_id— usereply_parameters - Legacy
answerCallbackQuery(id, text, showAlert)/answerCallbackQuery([options])signatures — useanswerCallbackQuery(id, options) NTBA_FIX_350environment flag —filename/contentTypeare now always auto-resolved
Fixed
- String errors now include timestamps in console output
Full Changelog: https://github.com/yagop/node-telegram-bot-api/compare/v0.67.0...v1.0.0