ping()¶
- async Client.ping()¶
Measure the round-trip network latency to the connected Telegram data center.
Usable by Users Bots- Parameters:
attempts (
int, optional) – The number of ping attempts to measure. If greater than 1, the average latency across all attempts is returned. Defaults to 1.- Returns:
float– The round-trip time (RTT) latency in milliseconds, rounded to 2 decimal places.
Example
# Single ping measurement latency = await app.ping() print(f"Latency: {latency} ms") # Average of 3 pings avg_latency = await app.ping(attempts=3) print(f"Average latency: {avg_latency} ms")