What's the method for counting Telegram bot users?

Hey everyone,

I’ve noticed that Telegram recently introduced an in-app store where every bot shows its user count. I’m wondering if there is a way to retrieve the user count for a specific bot through the Telegram API.

I checked the available documentation but didn’t find any explanation on how this number is derived or whether an API endpoint exists for this purpose. Has anyone managed to access this information programmatically?

It would be really useful for monitoring bot engagement and growth. I’d appreciate any guidance on this matter!

# Sample code for a different approach
import telegram_bot_sdk as tbsdk

bot_instance = tbsdk.Bot('YOUR_BOT_TOKEN')

# Hypothetical function to fetch the number of active users
active_user_count = bot_instance.fetch_active_users()

print(f'Active users: {active_user_count}')

Thanks a lot for your help!

hey there, i’ve been messin with telegram bots too. sadly, there’s no official way to get exact user counts thru the API. but i’ve found a workaround - try using the getChatMembersCount method for groups/channels ur bot’s in. it’s not perfect, but gives u a rough idea. just remember it only works for public chats where ur bot’s an admin.

I’ve been working with Telegram bots for a while, and unfortunately there’s no official way to get an exact user count through the API. The numbers shown in the in-app store are likely internal metrics that Telegram doesn’t expose publicly.

That said, I’ve found some workarounds that can give you a good estimate. One approach I’ve used is tracking unique user IDs that interact with the bot. You can store these in a database and increment a counter for new users. It’s not perfect, but it gives you a sense of overall reach.

For active users, I typically look at interactions within the last 7-14 days. This helps filter out inactive accounts and gives a more accurate picture of current engagement. Just be mindful of data privacy regulations when storing user information.

While not ideal, these methods have helped me gauge bot performance and growth over time. Hope this gives you some ideas to work with!

As far as I’m aware, Telegram doesn’t provide a direct API endpoint to retrieve the total user count for a bot. The in-app store display is likely based on internal Telegram metrics not accessible to developers.

However, you can approximate user engagement by tracking interactions. I’ve had success maintaining a database of unique user IDs who’ve interacted with my bot, incrementing a counter for new users. This gives a rough estimate of total reach.

For active users, I periodically clean inactive IDs and only count those who’ve interacted within a set timeframe (e.g. last 30 days). It’s not perfect, but provides useful insights for tracking growth and engagement trends over time.

Remember to comply with data retention policies and user privacy considerations when implementing such tracking.