All Projects → zerobias → Telegram Mtproto

zerobias / Telegram Mtproto

Licence: mit
Telegram client api (MTProto) library

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Telegram Mtproto

Mtproto
Full-native go implementation of Telegram API
Stars: ✭ 566 (+4.43%)
Mutual labels:  telegram-api, telegram, mtproto
Mtproto Core
Telegram API JS (MTProto) client library for browser and nodejs
Stars: ✭ 242 (-55.35%)
Mutual labels:  telegram-api, telegram, mtproto
Telethon
Pure Python 3 MTProto API Telegram client library, for bots too!
Stars: ✭ 5,805 (+971.03%)
Mutual labels:  telegram-api, telegram, mtproto
Telegramd
Unofficial open source telegram server written in golang
Stars: ✭ 609 (+12.36%)
Mutual labels:  telegram-api, telegram, mtproto
Grammers
(tele)gramme.rs - use Telegram's API from Rust
Stars: ✭ 109 (-79.89%)
Mutual labels:  telegram-api, telegram, mtproto
Madelineproto
Async PHP client/server API for the telegram MTProto protocol
Stars: ✭ 1,776 (+227.68%)
Mutual labels:  telegram-api, telegram, mtproto
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (-79.34%)
Mutual labels:  telegram-api, telegram, mtproto
Pyrogram
Telegram MTProto API Client Library and Framework in Pure Python for Users and Bots
Stars: ✭ 2,252 (+315.5%)
Mutual labels:  telegram-api, telegram, mtproto
nimgram
An MTProto client written in Nim 👑
Stars: ✭ 61 (-88.75%)
Mutual labels:  telegram-api, mtproto
tdlight-java
Complete Bot and Userbot Telegram library based on TDLib
Stars: ✭ 128 (-76.38%)
Mutual labels:  telegram-api, mtproto
tdlight-telegram-bot-api
The TDLight Telegram Bot API is an actively enhanced fork of the original Bot API, featuring experimental user support, proxies, unlimited files size, and more.
Stars: ✭ 71 (-86.9%)
Mutual labels:  telegram-api, mtproto
aiotdlib
Python asyncio Telegram client based on TDLib https://github.com/tdlib/td
Stars: ✭ 63 (-88.38%)
Mutual labels:  telegram-api, mtproto
Python Telegram
Python client for the Telegram's tdlib
Stars: ✭ 246 (-54.61%)
Mutual labels:  telegram-api, telegram
Go Tdlib
Golang Telegram TdLib JSON bindings
Stars: ✭ 244 (-54.98%)
Mutual labels:  telegram-api, telegram
WilliamButcherBot
Telegram Group Manager Bot Written In Python Using Pyrogram.
Stars: ✭ 187 (-65.5%)
Mutual labels:  telegram, mtproto
WTelegramClient
Telegram client API library written 100% in C# and .NET Standard
Stars: ✭ 192 (-64.58%)
Mutual labels:  telegram-api, mtproto
tg
`telegram-cli` for Telegram IM
Stars: ✭ 306 (-43.54%)
Mutual labels:  telegram, telegram-api
node-tg-native
Telegram Native lib
Stars: ✭ 22 (-95.94%)
Mutual labels:  telegram, mtproto
telegram-bot-delphi
A simple example of integration with a telegram bot API.
Stars: ✭ 22 (-95.94%)
Mutual labels:  telegram, telegram-api
mtproxy autoinstaller
MTProxy autoinstaller for Ubuntu
Stars: ✭ 25 (-95.39%)
Mutual labels:  telegram, mtproto

‼️ Better use @mtproto/core

telegram-mtproto

npm version

Telegram Mobile Protocol (MTProto) library in es6

About MTProto..

MTProto is the Telegram Messenger protocol "designed for access to a server API from applications running on mobile devices".

The Mobile Protocol is subdivided into three components (from the official site):

  • High-level component (API query language): defines the method whereby API queries and responses are converted to binary messages.

  • Cryptographic (authorization) layer: defines the method by which messages are encrypted prior to being transmitted through the transport protocol.

  • Transport component: defines the method for the client and the server to transmit messages over some other existing network protocol (such as, http, https, tcp, udp).

telegram-mtproto in short..

No more additional libs. The telegram-mtproto library implements the Mobile Protocol and provides all features for work with telegram protocol:

  • A high level api for server connection

  • Promise-based API

  • HTTP connections implemented in the transport layer

  • Web worker support for blazing fast crypto math works in background

  • A cipher implementation for AES and RSA encryption in the security layer

  • Both plain-text and encrypted message to communicate data with the server

  • Diffie-Hellman key exchange supported by the prime factorization function implemented in the security layer

  • MTProto TL-Schema compilation as javascript classes and functions

  • Custom async storage support for saving user data between sessions

Installation

$ npm install --save [email protected]

Usage

import MTProto from 'telegram-mtproto'

const phone = {
  num : '+9996620001',
  code: '22222'
}

const api = {
  layer          : 57,
  initConnection : 0x69796de9,
  api_id         : 49631
}

const server = {
  dev: true //We will connect to the test server.
}           //Any empty configurations fields can just not be specified

const client = MTProto({ server, api })

async function connect(){
  const { phone_code_hash } = await client('auth.sendCode', {
    phone_number  : phone.num,
    current_number: false,
    api_id        : 49631,
    api_hash      : 'fb050b8f6771e15bfda5df2409931569'
  })
  const { user } = await client('auth.signIn', {
    phone_number   : phone.num,
    phone_code_hash: phone_code_hash,
    phone_code     : phone.code
  })

  console.log('signed as ', user)
}

connect()

Above we used two functions from the API.

type auth.sendCode = (phone_number: string, sms_type: int,
  api_id: int, api_hash: string, lang_code: string) => {
    phone_registered: boolean,
    phone_code_hash: string,
    send_call_timeout: int,
    is_password: boolean
  }

type auth.signIn = (phone_number: string, phone_code_hash: string, phone_code: string) => {
  expires: int,
  user: User
}

More about them, as well as about many other methods, you can read in the official documentation.

Additional examples can be obtained from examples folder.

Storage

You can use your own storages like localForage for saving data. Module accepts the following interface

interface AsyncStorage {
  get(key: string): Promise<any>;
  set(key: string, value: any): Promise<void>;
  remove(...keys: string[]): Promise<void>;
  clear(): Promise<void>;
}
import { MTProto } from 'telegram-mtproto'
import { api } from './config'
import CustomStorage from './storage'

const client = MTProto({
  api,
  app: {
    storage: CustomStorage
  }
})

License

The project is released under the Mit License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].