Skip to Content
ReferencePythonOverview

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 opentele2

Modules

ModuleWhat it holds
opentele2.tdTDesktop, Account, AuthKey, AuthKeyType and the MTP config view of an account
opentele2.tlTelegramClient, Telethon’s client with API profiles, QR login, session admin and .session + .json pairs
opentele2.apiAPI and its eight client classes, APIData, LoginFlag, UseCurrentSession, CreateNewSession
opentele2.devicesThe device classes and DeviceInfo
opentele2.fingerprintPlatformVersions, FingerprintConfig, StrictMode, initConnection validation, layer and msg_id helpers
opentele2.consistencyConsistencyChecker, ConsistencyReport, CheckResult
opentele2.browserHeaderGenerator, FingerprintGenerator and the fingerprint dataclasses
opentele2.exceptionOpenTeleException and its subclasses, Expects, the core error mapping
opentele2._nativeThe 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 cryptg module when no real cryptg is 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_VERSIONS and the API classes. Set OPENTELE_NO_FETCH=1 to 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