tdata_reader
Read Telegram Desktop's tdata folder and extract everything needed to
spin up a Telethon client — without PyQt5 and without any native crypto
extension.
The library is a stripped-down, dependency-light fork of the data-reading parts of opentele: it only does the read-tdata → Telethon-session direction, which is the common use case in account-management tools.
Install
pip install tdata-reader
The only runtime dependency is telethon. Telethon's pure-Python AES
implementation is used as a fallback, so cryptg/tgcrypto are
optional — install one of them for a noticeable speed-up if you plan to
also use the resulting client at scale.
Usage
from tdata_reader import read_tdata
acc = read_tdata("/path/to/tdata") # first account
print(acc.user_id, acc.dc_id) # extracted from tdata
print(acc.api_id, acc.api_hash) # TelegramDesktop preset
print(acc.device_model, acc.system_version) # ditto
session_string = acc.to_string_session() # ready for StringSession
Plug into Telethon:
from telethon import TelegramClient
from telethon.sessions import StringSession
client = TelegramClient(
StringSession(session_string),
**acc.as_init_connection_kwargs(),
)
Passcode-protected tdata:
acc = read_tdata("/path/to/tdata", passcode="my-local-passcode")
Multi-account tdata (TDesktop supports up to 3 accounts):
from tdata_reader import read_all_tdata
for acc in read_all_tdata("/path/to/tdata"):
print(acc.user_id, acc.to_string_session())
Mask the session as a different official client:
from tdata_reader import read_tdata, TelegramAndroid
acc = read_tdata("/path/to/tdata", api=TelegramAndroid)
# acc.api_id / acc.api_hash / acc.device_model now match TelegramAndroid
Returned data
TDataAccount fields:
| Field | Source | Notes |
|---|---|---|
user_id |
tdata | Telegram user id |
dc_id |
tdata | Main data-center id (1–5) |
auth_key |
tdata | 256-byte authorization key for the main DC |
dc_ip, dc_port |
built-in | Production endpoint for dc_id |
extra_auth_keys |
tdata | {dc_id: 256-byte key} for non-main DCs |
api_id, api_hash |
API preset | Defaults to TelegramDesktop (2040) |
device_model, system_version, app_version |
API preset | Used by Telethon's initConnection |
lang_code, system_lang_code, lang_pack |
API preset | Same |
Note on device fields.
device_model,system_version,app_version,lang_code,system_lang_codeare not stored inside tdata — Telegram clients send them ininitConnectionat runtime. The library exposes the official preset values so that the resulting Telethon client looks identical to a real Telegram Desktop.
Exceptions
All exceptions inherit from TDataError:
TDataFileNotFound— required files (key_data*,data*, …) missing.TDataBadDecryptKey— wrong passcode or tampered/corrupt encrypted blob.TDataCorrupted— files are present but their contents don't parse.TDataUnsupportedDc— account references a DC id not in the built-in production endpoint table.
License
MIT.
Metadata
Release files for tdata-reader 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tdata_reader-0.1.0.tar.gz | 11.4 kB | Without provenance | Details for tdata_reader-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tdata_reader-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tdata_reader-0.1.0-py3-none-any.whl |
Total release size: 23.8 kB
Release files / tdata_reader-0.1.0.tar.gz
| Download URL | tdata_reader-0.1.0.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0de207bc11139738b4eb7183f76f27e39b3df39882a88d997f2611ab7a76a3a
|
|
BLAKE2b-256 checksum How to use checksums |
79d1e4e3dfb34b7a2dac7d6c1c8fc4ca1b56fbbf4d878a4f7b29b6090b9f1446
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Release files / tdata_reader-0.1.0-py3-none-any.whl
| Download URL | tdata_reader-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f83a4e45f82ff963d461ceb28d375ad133558decad49e2a976ab0e68c35baea
|
|
BLAKE2b-256 checksum How to use checksums |
d74f32098b7d06c24c0393e1ec0b12dad98ba096e45f8230aa8df9437c169914
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.2
|
Security for tdata-reader 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.