CLI quick start¶
opentele-ng ships a small CLI for the common one-shot workflows. After pip install opentele-ng, the opentele-ng command is on your PATH.
Inspect a tdata folder (read-only)¶
tdata: /path/to/Telegram/tdata
AppVersion: 6008002
accounts: 2
main account idx: 0
└─ [0] UserId=6925730240 DC=4 authKey_sha256=775161c1b987143b…
└─ [1] UserId=8001234567 DC=5 authKey_sha256=eac0a1a2cc10a5ce…
Add --json to get a machine-readable dump (suitable for piping into jq or saving alongside other metadata):
Convert tdata → Telethon .session file¶
By default this creates a new Telegram session (Telegram Desktop's existing session keeps working separately). Pass --use-current-session to reuse the live session instead:
Add --force to replace an existing output file. Conversion builds a fresh
SQLite session beside the destination and publishes it only after disconnect
has finished. The old file stays intact if conversion fails, and its cached
entities, update state and takeout ID are not carried into the new account.
Without --force, an output created by another process during conversion is
also preserved. The output directory must already exist.
Exit codes¶
| Code | Meaning |
|---|---|
| 0 | Success. |
| 2 | The tdata path is not a directory / does not exist. |
| 3 | TDesktop failed to load (corrupt tdata, wrong path). |
| 4 | The .session file could not be created or published. |
| 5 | Output file exists; rerun with --force. |
| 130 | Interrupted (Ctrl-C). |
Scripting¶
The CLI is the right tool when you don't need to customise anything. As soon as you want to set a custom API ID, pass extra Telethon options, or do batch operations, switch to the Python API — see convert-tdata-to-telethon.md.