Telegram session tooling for Python
Convert tdata
and Telethon sessions.
opentele2 provides Python APIs for Telegram Desktop session conversion, Telethon integration, official API templates, and device fingerprint generation.
Bidirectional conversion Official API flows Telethon-friendly
Features
Convert both ways
Convert Telegram Desktop tdata sessions to Telethon sessions and export Telethon sessions back to tdata.
Use official Telegram APIsSelect built-in API definitions for Telegram Desktop, Android, iOS, macOS, and web clients.
Generate credible fingerprintsGenerate device metadata from bundled desktop, mobile, and browser profiles.
Learn by exampleUse focused examples for conversion flows, API selection, and session JSON files.
Start in the right place
Documentation
Learn the core concepts, classes, and API reference.
ExamplesFollow working examples for common session conversion tasks.
First runTake the shortest route from install to a working script.
Quick start
Install the package:
pip install --upgrade opentele2Convert Telegram Desktop tdata to a Telethon session:
import asyncio
from opentele2.api import API, CreateNewSession
from opentele2.td import TDesktop
async def main() -> None:
tdesk = TDesktop(r"C:\Users\<username>\AppData\Roaming\Telegram Desktop\tdata")
api = API.TelegramIOS.Generate()
client = await tdesk.ToTelethon("new.session", CreateNewSession, api)
await client.connect()
await client.PrintSessions()
asyncio.run(main())See the conversion example for the complete workflow.
A New Era for opentele
opentele2 is the rebirth of the original opentele project. The library is now actively maintained and under continued development. We are committed to keeping it up-to-date with the latest versions of Telegram Desktop and Telethon, fixing bugs, and adding new features.
Key Enhancements
- PyQt5 Removed: The PyQt5 library has been completely removed. Its functionality has been reimplemented in pure Python to eliminate overhead and avoid installing unnecessary heavy dependencies.
- New Fingerprints: Some improvements of device information generation. The library now uses a new device database.
Last updated on