Python reference
The PyPI package opentele2 (Python 3.8+, abi3 wheels) is a native wheel built from the Rust
core. It depends on telethon and, below Python 3.10, typing_extensions.
pip install opentele2Modules
| Module | What it holds |
|---|---|
opentele2.td | TDesktop, Account, AuthKey, AuthKeyType and the MTP config view of an account |
opentele2.tl | TelegramClient, Telethon’s client with API profiles, QR login, session admin and .session + .json pairs |
opentele2.api | API and its eight client classes, APIData, LoginFlag, UseCurrentSession, CreateNewSession |
opentele2.devices | The device classes and DeviceInfo |
opentele2.fingerprint | PlatformVersions, FingerprintConfig, StrictMode, initConnection validation, layer and msg_id helpers |
opentele2.consistency | ConsistencyChecker, ConsistencyReport, CheckResult |
opentele2.browser | HeaderGenerator, FingerprintGenerator and the fingerprint dataclasses |
opentele2.exception | OpenTeleException and its subclasses, Expects, the core error mapping |
opentele2._native | The extension module everything above computes through |
What importing does
import opentele2 imports api, consistency, fingerprint, td and tl, and on the way:
- registers the core’s AES-IGE as the top-level
cryptgmodule when no realcryptgis installed, before anything imports Telethon; - rebinds Telethon’s AES-CTR, PQ factorisation, SHA-1/SHA-256 and password hashing to the core,
whether Telethon was imported before or after
opentele2; - fetches the current client versions once and applies them to
PLATFORM_VERSIONSand theAPIclasses. SetOPENTELE_NO_FETCH=1to stay on the built-in versions.
Tip:
The method names of TDesktop, Account and TelegramClient keep their capitalised form
(LoadTData, ToTelethon, FromSessionJson); the rest of the package uses snake case.
Last updated on