Skip to main content

An experimental full MTProto Python client library

Project description

TGLib

PyPI Version Python Versions License Stars Status

An experimental, full-featured MTProto Python client library for Telegram.
Built from scratch. Async-first. Lightweight.


โš ๏ธ Experimental

TGLib is currently in early development. APIs may change without notice. Use in production at your own risk. Contributions and feedback are welcome!


โœจ Features

  • ๐Ÿ” Full MTProto implementation โ€” low-level Telegram protocol support
  • โšก Async-first โ€” built entirely on asyncio
  • ๐Ÿ—„๏ธ Session persistence โ€” via aiosqlite
  • ๐Ÿ”’ Encryption โ€” powered by pyaes and pycryptodome
  • ๐Ÿชถ Lightweight โ€” minimal dependencies, maximum control
  • ๐Ÿ Python 3.10+ โ€” uses modern Python features

๐Ÿ“ฆ Installation

From PyPI:

pip install tglib

From source:

git clone https://github.com/ankit-chaubey/TGLib.git
cd TGLib
pip install -e .

๐Ÿš€ Quick Start

from tglib import Client

client = Client(
    api_id=YOUR_API_ID,
    api_hash="YOUR_API_HASH",
    session="my_session"
)

async def main():
    await client.start()
    me = await client.get_me()
    print(f"Logged in as: {me.first_name}")

client.run(main())

Get your api_id and api_hash from my.telegram.org


๐Ÿ”ง Dependencies

Package Purpose
pyaes AES encryption for MTProto
pycryptodome RSA and additional crypto
aiosqlite Async session storage

๐Ÿ“ Project Structure

TGLib/
โ”œโ”€โ”€ tglib/
โ”‚   โ”œโ”€โ”€ __init__.py       # Entry point
โ”‚   โ”œโ”€โ”€ client/           # Client logic
โ”‚   โ”œโ”€โ”€ crypto/           # Encryption & MTProto
โ”‚   โ”œโ”€โ”€ network/          # TCP transport
โ”‚   โ””โ”€โ”€ types/            # Telegram types
โ”œโ”€โ”€ setup.py
โ””โ”€โ”€ README.md

๐Ÿค Contributing

Contributions are very welcome! Here's how to get started:

# Fork the repo, then:
git clone https://github.com/YOUR_USERNAME/TGLib.git
cd TGLib
pip install -e .
  1. Create a new branch: git checkout -b feature/your-feature
  2. Make your changes
  3. Push and open a Pull Request

๐Ÿ› Issues & Feedback

Found a bug or have a suggestion?
๐Ÿ‘‰ Open an issue


๐Ÿ“„ License

This project is licensed under the MIT License โ€” see the LICENSE file for details.


๐Ÿ‘ค Author

Ankit Chaubey
๐Ÿ“ง ankitchaubey.dev@gmail.com
๐Ÿ™ github.com/ankit-chaubey


Made with โค๏ธ and Python

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tglib-0.1.0.tar.gz (410.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tglib-0.1.0-py3-none-any.whl (455.0 kB view details)

Uploaded Python 3

File details

Details for the file tglib-0.1.0.tar.gz.

File metadata

  • Download URL: tglib-0.1.0.tar.gz
  • Upload date:
  • Size: 410.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tglib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a1657743d13337e53f92b58b934d194415fec3a25aa3c4bfe74f41c5eaebbd8
MD5 08f0381e1aaf66b63e9cf9a70d185632
BLAKE2b-256 0ce35b19db5851638fc6641344b26c60bd1cc330b4e8154d046af876c4239ee3

See more details on using hashes here.

File details

Details for the file tglib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tglib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 455.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tglib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 41af2004e64f9e7af37a7809cd610496c2004ee1b8bd8055a71b678f6b4213c8
MD5 adeb4da13af223341b02b7e9385397c5
BLAKE2b-256 fcd75335c01bef31b5aa3c1a874a4c585c8c919fb6f0f42818d48953fbbe6223

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page