Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Stats & Analytics

ferogram exposes Telegram’s channel and supergroup statistics endpoints.

Note: Statistics are only available for channels with at least 500 subscribers and for supergroups that meet Telegram’s threshold. The statistics DC must be reachable.


Broadcast channel statistics

#![allow(unused)]
fn main() {
let stats = client.stats("@mychannel").await?;
// dark=true requests dark-themed graph images
}

Returns tl::enums::stats::BroadcastStats. Key fields:

#![allow(unused)]
fn main() {
let tl::enums::stats::BroadcastStats::BroadcastStats(s) = stats;

// Follower count range
println!("Followers: {} (prev {})", s.followers.current, s.followers.previous);

// Views per post
println!("Views/post: {} (prev {})", s.views_per_post.current, s.views_per_post.previous);

// Shares per post
println!("Shares/post: {} (prev {})", s.shares_per_post.current, s.shares_per_post.previous);
}

BroadcastStats also contains graph references (s.growth_graph, s.followers_graph, s.top_hours_graph, s.interactions_graph, s.iv_interactions_graph, s.views_by_source_graph, s.new_followers_by_source_graph, s.languages_graph) that can be fetched via stats.loadAsyncGraph if they carry an async token.


Supergroup (megagroup) statistics

#![allow(unused)]
fn main() {
let stats = client.stats("@mysupergroup").await?;
}

Returns tl::enums::stats::MegagroupStats. Key fields:

#![allow(unused)]
fn main() {
let tl::enums::stats::MegagroupStats::MegagroupStats(s) = stats;

println!("Members: {} (prev {})", s.members.current, s.members.previous);
println!("Messages: {} (prev {})", s.messages.current, s.messages.previous);
println!("Viewers: {} (prev {})", s.viewers.current, s.viewers.previous);
println!("Posters: {} (prev {})", s.posters.current, s.posters.previous);
}

MegagroupStats also exposes s.top_posters, s.top_admins, s.top_inviters (lists of users with message/invite counts) and graph references for member growth, languages, messages by hour/weekday.


Online member count

Get the current approximate number of online members in a group or channel:

#![allow(unused)]
fn main() {
let online = client.get_online_count("@mychannel").await?;
println!("{online} members are online right now");
}

Poll statistics

#![allow(unused)]
fn main() {
let stats = client.poll_results(peer.clone(), msg_id).await?;
}

Returns tl::types::stats::PollStats. Contains a votes_graph field with a StatsGraph showing vote distribution over time. Use stats.loadAsyncGraph if the graph carries an async token.

#![allow(unused)]
fn main() {
let tl::enums::stats::PollStats::PollStats(s) = stats;
// s.votes_graph: tl::enums::StatsGraph
}

Only available for polls in channels that meet Telegram’s stats threshold.