Scrape Telegram Members

If you need to get a list of all the members from a Telegram group then this is the right article for you. In this article, I will be showing you steps to successfully scrape Telegram members from any public Telegram group.

Installing Telethon

We need to install Telethon Library in order to scrape members from any group. You can install Telethon by using pip and running the below commands.

pip install Telethon

Installing Pandas

We also need to install the Pandas library as we will be saving all the scraped members in a CSV or Excel File. You can install Pandas by running the below command.

pip install pandas

Getting Telegram API ID and API Hash

You will need to get a Telegram API ID and API Hash in order to programmatically access your Telegram account. You will need to register to My Telegram Org in order to get these details.

Python Program to Scrape Telegram Members

After following the above steps, now you are ready to start developing the Python program to scrape Telegram Members. Below is the complete Python code, I will be explaining the important part of the code.

import pandas as pd
from telethon.sync import TelegramClient
from import InviteToChannelRequest
from import ResolveUsernameRequest
from import GetDialogsRequest, AddChatUserRequest
from import InputPeerEmpty
from import InputPeerChannel
from import InputPeerUser

api_id = "GIVE YOUR API ID"
api_hash = "GIVE YOUR API HASH"

client = TelegramClient('test', api_id, api_hash)

# Provide the name of the Telegram group.
# In below example we are scraping members from vikasjhahelloworld001 Group

target_group = client.get_entity("vikasjhahelloworld001")

print("Group ID: {}, Group Hash: {}".format(, target_group.access_hash))

target_group_entity = InputPeerChannel(,target_group.access_hash)

# Change the location of the file as per your need

df = pd.read_excel("C:\\crypto\\members.xls")
users = df.to_records(index=False)

for i in range(6):
        print("Adding: {}".format(users[i]['username']))
        print("Userid: {} , user_access_hash: {}".format(users[i]['id'], users[i]['access_hash']))
        user_to_add =InputPeerUser(users[i]['id'], users[i]['access_hash'])
        print("user to add: {}".format(user_to_add))
    except Exception as e:

Learn to Scrape Telegram Group Messages

Comments are closed.

Scroll to Top