modern typescript library for mtproto. supports browsers, node/bun, deno and more! github mirror: https://github.com/mtcute/mtcute
Find a file
alina sireneva 9e952856fe
Some checks failed
Tests / test-deno (pull_request) Successful in 48s
Tests / test-node (node22) (pull_request) Successful in 1m17s
Tests / test-node (node20) (pull_request) Successful in 1m19s
Tests / test-node (node18) (pull_request) Successful in 1m23s
Tests / test-bun (pull_request) Successful in 1m33s
Tests / test-web (pull_request) Successful in 2m2s
Build and deploy typedoc / build (pull_request) Successful in 5m8s
Tests / lint (pull_request) Successful in 5m42s
Tests / e2e-deno (pull_request) Has been cancelled
Tests / e2e (pull_request) Has been cancelled
Tests / test-deno (push) Successful in 46s
Tests / test-node (node20) (push) Successful in 1m17s
Tests / test-node (node22) (push) Successful in 1m18s
Tests / test-node (node18) (push) Successful in 1m24s
Tests / test-bun (push) Successful in 1m33s
Tests / test-web (push) Successful in 2m0s
Build and deploy typedoc / build (push) Successful in 5m8s
Tests / lint (push) Successful in 5m39s
Tests / e2e-deno (push) Has been cancelled
Tests / e2e (push) Has been cancelled
ci: timeout+retry for e2e tests
2025-04-09 06:44:42 +03:00
.config chore: use vitest directly for bun and deno 2025-03-02 09:01:40 +03:00
.forgejo ci: timeout+retry for e2e tests 2025-04-09 06:44:42 +03:00
docs Fix convertFromTdata example 2025-03-26 00:57:19 +03:00
e2e test(e2e): force import session + updated deno.lock 2025-04-08 11:51:11 +03:00
packages chore(create-bot): use tsx for prod :3 2025-04-09 03:47:53 +03:00
scripts chore(release): v0.22.3 2025-03-25 22:16:08 +00:00
.dockerignore chore: initial migration to fuman networking 2024-09-29 04:13:48 +03:00
.editorconfig feat: tl reference web application 2021-04-14 18:08:53 +03:00
.gitattributes Initial commit 2021-04-08 12:19:38 +03:00
.gitignore chore: moved docs inside the main repo 2025-01-17 08:50:35 +03:00
.npmrc build: use builds from pkg.pr.new 2024-11-20 19:44:25 +03:00
.nvmrc chore: better dependencies management 2023-06-04 17:00:33 +00:00
build.config.js chore: moved docs inside the main repo 2025-01-17 08:50:35 +03:00
eslint.config.js feat!: deserialization for backwards compatibility 2025-02-20 23:51:34 +03:00
LICENSE chore: lowercase name 2024-03-20 13:56:18 +03:00
package.json chore(release): v0.22.3 2025-03-25 22:16:08 +00:00
pnpm-lock.yaml chore: use vitest directly for bun and deno 2025-03-02 09:01:40 +03:00
pnpm-workspace.yaml test(e2e): massive rework of e2e tests 2024-12-07 09:08:30 +03:00
README.md chore!: removed crypto-node 2025-02-09 19:53:52 +03:00
tsconfig.json fix: fixed deno types and build 2025-01-01 21:55:42 +03:00

mtcute logo

modern typescript library for mtproto
documentation  •  api reference  •  telegram chat

Tests CI tl layer npm alpha version

Warning

mtcute is currently in alpha stage: the api is not very stable yet, and there may be a lot of bugs feel free to try it out, though, any feedback is appreciated!

import { TelegramClient } from '@mtcute/node'
import { Dispatcher, filters } from '@mtcute/dispatcher'

const tg = new TelegramClient({
    apiId: Number.parseInt(process.env.API_ID),
    apiHash: process.env.API_HASH,
    storage: 'my-account'
})
const dp = Dispatcher.for(tg)

dp.onNewMessage(filters.chat('private'), async (msg) => {
    await msg.replyText('hiiii from mtcute! 🌸')
})

const self = await tg.start({ /* optional params */ })
console.log(`✨ logged in as ${self.displayName}`)

mtcute is a modern, performant and cute mtproto library and bot framework, supporting both web and nodejs.

quick start

🤖 just starting a (user)bot? use the scaffolding tool:

pnpm create @mtcute/bot

🏭 want to integrate it into your existing nodejs app? use the nodejs package:

pnpm add @mtcute/node

building something for web? use the web package:

pnpm add @mtcute/web

🚀 using the newfangled runtimes? we've got you covered:

  • bun: bun add @mtcute/bun
  • deno: import { TelegramClient } from 'jsr:@mtcute/deno'

learn more: guide

features

  • 🍰 simple: mtcute hides all the complexity and provides a clean and modern api
  • compatible: mtcute supports almost everything bot api does, and even more!
  • 🍡 lightweight: running instance uses less than 50 mb of ram
  • 🛡️ type-safe: most of the apis (including mtproto) are strictly typed to help your workflow
  • ⚙️ hackable: almost every aspect of the library is customizable, including networking and storage
  • 🕙 up-to-date: mtcute uses the latest TL schema to provide the newest features as soon as possible

cat in the readme 🐈

project goals

mtcute strives to:

  • be customizable enough to fit most of the possible use-cases
  • be lightweight, both in terms of runtime and bundle size
  • support (theoretically) any environment without much hassle
  • provide a solid foundation for all kinds of applications on telegram platform
  • provide a convenient high-level api for the most commonly used features

mtcute is NOT and will never be:

  • a library for spam/flood or otherwise malicious activities
  • a fully feature-complete library - highlevel apis will never cover the entirety of the apis. feel free to contribute, though!
  • a drop-in replacement for (insert library name)
  • a teapot

setting up for development

git clone https://github.com/mtcute/mtcute
fnm use # or `nvm use`
cd mtcute
pnpm install --frozen-lockfile

# generate code from tl schema
pnpm -C packages/tl run gen-code

acknowledgements

some parts were based on or greatly inspired by these projects:

thanks @dotvhs for the logo <3