Skip to Content
GuidesLive client versions

Live client versions

An app version far behind the official release is a tell. opentele2 ships a built-in set of versions and can fetch the current ones from the clients’ public release sources: Telegram Desktop, Android, Telegram X, iOS, macOS, Web K, Web A, plus stable Chrome and Firefox for the web devices. The fetch returns a patch, the fields some source answered, which you apply onto a versions record.

Note:

Fetching sends plain HTTP requests to public release feeds and nothing about any account. It never fails for the network: a source that fails or times out leaves its fields out, and with no network the patch is empty.

Know who fetches when

Fetches by itselfFetch on requestTurn it off
Pythononce per process, at import opentele2_native.fetch_versions(timeout)OPENTELE_NO_FETCH before the import
NodeneverfetchVersions(timeoutMs)nothing to turn off
Rustneveropentele2_versions::fetch_all(timeout)nothing to turn off; leave the crate out

Each request has a timeout, 10 seconds by default.

Read the built-in versions

The built-in set ships inside the core. Every function that takes versions (profiles, Generate, validation, consistency expectations) uses it when you pass none.

offline.py
from opentele2 import _native versions = _native.platform_versions() print(versions["android_app_version"], versions["desktop_app_version"], versions["chrome_version"])

opentele2.fingerprint.get_platform_versions() returns PLATFORM_VERSIONS, the record the API classes read: the built-in set with the import-time patch applied.

Fetch the current versions

fetch.py
from opentele2.fingerprint import get_platform_versions versions = get_platform_versions() # fetched once, when opentele2 was imported print(versions.android_app_version, versions.chrome_version, versions.firefox_version)

On any failure the built-in versions stay. _native.fetch_versions(10.0) runs the nine sources again and returns the patch as a dict, without applying it.

Apply the patch

A patch is written onto a versions record field by field, with two rules: desktop_app_version is reported but never applied, because the Telegram Desktop version stays bound to the one written into tdata (7.3.1); and chrome_version rebuilds user_agent of the default web profiles.

apply.py
from opentele2 import _native # A patch from _native.fetch_versions(), or one of your own: patch = {"chrome_version": "156.0.0.0", "android_app_version": "13.1.0"} versions = _native.apply_versions_patch(_native.platform_versions(), patch) print(versions["user_agent"]) # ... Chrome/156.0.0.0 Safari/537.36 print(_native.profile("TelegramAndroid", versions)["app_version"]) # 13.1.0 (7183) print(_native.generate("TelegramWeb_A", "my-id", None, versions)["device_model"])
Note:

The Chrome and Firefox majors decide the web device pool, so a web device generated for a unique id changes when either browser moves to a new major. Store the unique id, not the device, and validate a profile against the same versions it was built with.

Stay offline

Set OPENTELE_NO_FETCH before opentele2 is imported, for tests, CI and machines without network:

terminal
OPENTELE_NO_FETCH=1 python main.py
main.py
import os os.environ["OPENTELE_NO_FETCH"] = "1" # before the first import of opentele2 import opentele2 # noqa: E402

Next

Last updated on