mtcute/packages/core
mtcute-bot 6c9f4c897d
All checks were successful
Tests / lint (push) Has been skipped
Tests / test-node (node20) (push) Successful in 1m41s
Tests / test-node (node22) (push) Successful in 1m41s
Tests / test-node (node18) (push) Successful in 1m47s
Tests / test-deno (push) Successful in 1m41s
Tests / test-bun (push) Successful in 1m48s
Tests / test-web (chromium) (push) Successful in 1m47s
Tests / test-web (firefox) (push) Successful in 1m56s
Tests / e2e (push) Has been skipped
Tests / e2e-deno (push) Has been skipped
Build and deploy typedoc / build (push) Successful in 6m38s
chore(release): v0.20.1
2025-01-27 15:44:46 +00:00
..
scripts fix(core): typo in method name 2025-01-01 06:47:23 +03:00
src feat(core): allow excluding internal errors from retrying 2025-01-27 18:20:34 +03:00
.gitignore tests(core): added e2e and fuzzing tests 2021-06-15 03:12:22 +03:00
build.config.js chore: bumped @antfu/eslint-config + reformat 2024-12-03 09:55:37 +03:00
package.json chore(release): v0.20.1 2025-01-27 15:44:46 +00:00
README.md chore: migrate to antfu eslint config (+ reformat) 2024-08-18 07:18:13 +03:00
tsconfig.json build: build with vite (initial) 2024-08-24 22:55:25 +03:00

@mtcute/core

📖 API Reference

Platform-agnostic MTProto implementation and auxiliary utilities.

Features

  • MTProto 2.0: Implements the full MTProto protocol, including all the encryption and serialization
  • 2FA support: Provides utilities for 2-step verification
  • Hackable: Bring your own storage, transport, and other components to customize the library to your needs
  • Magical: Handles reconnections, connection pooling, DC redirections and other stuff for you
  • Updates handling: Implements proper updates handling, including ordering and gap recovery (learn more)
  • High-level: Includes a high-level API that wrap the MTProto APIs and provide a clean interface
  • Tree-shaking: You can import just the methods you need, and the rest will not be included into the bundle

Usage

import { BaseTelegramClient } from '@mtcute/core/client.js'

const tg = new BaseTelegramClient({
    apiId: 12345,
    apiHash: '0123456789abcdef0123456789abcdef',
    crypto: new MyCryptoProvider(),
    storage: new MyStorage(),
    transport: () => new MyTransport(),
})

tg.call({ _: 'help.getConfig' })
    .then(console.log)

Usage with high-level API

import { TelegramClient } from '@mtcute/core/client.js'

const tg = new TelegramClient({
    // ... same options as above
})

const self = await tg.start({
    phone: '+1234567890',
    code: () => prompt('Enter the code:'),
    password: 'my-password',
})
console.log(`✨ logged in as ${self.displayName}`)