Answer the question
In order to leave comments, you need to log in
How to get the number of channel subscribers in Telegram?
Good afternoon. For the purpose of enriching the ML model, I would like to collect data on the number of channel subscribers in the telegram. I am not the owner of the channel, but I would like to get the number of subscribers. Tell me how this can be done?
i tried the method getChatMemberCount
and got the view url
https://api.telegram.org/bot{api_id}:{api_hash}/[email protected]{url_channel}
. HTTPError: HTTP Error 401: Unauthorized
, apparently saying that I have nothing to do with this channel. Tell me, are there any options?
Answer the question
In order to leave comments, you need to log in
Either through a bot or through a client API.
Through the bot, you need to get the bot token from @BotFather and paste the token into your URL. Or use any convenient library:
import telebot
token = 'XXX'
channel = '@XYZ'
bot = telebot.TeleBot(token)
print(bot.get_chat_member_count(channel))
from telethon import TelegramClient, sync
from telethon.tl.functions.channels import GetFullChannelRequest
api_id = ZZZ
api_hash = 'YYY'
channel_name = 'XXX'
client = TelegramClient('session_name', api_id, api_hash)
client.start()
channel_connect = client.get_entity(channel_name)
channel_full_info = client(GetFullChannelRequest(channel=channel_connect))
print(channel_full_info.full_chat.participants_count)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question