get_chat_members()¶
-
Client.get_chat_members()¶ Get a chunk of the members list of a chat.
You can get up to 200 chat members at once. A chat can be either a basic group, a supergroup or a channel. You must be admin to retrieve the members list of a channel (also known as “subscribers”). For a more convenient way of getting chat members see
iter_chat_members().- Parameters
chat_id (
int|str) – Unique identifier (int) or username (str) of the target chat.offset (
int, optional) – Sequential number of the first member to be returned. Only applicable to supergroups and channels. Defaults to 0 1.limit (
int, optional) – Limits the number of members to be retrieved. Only applicable to supergroups and channels. Defaults to 200, which is also the maximum server limit allowed per method call.query (
str, optional) – Query string to filter members based on their display names and usernames. Only applicable to supergroups and channels. Defaults to “” (empty string) 2.filter (
str, optional) – Filter used to select the kind of members you want to retrieve. Only applicable for supergroups and channels. It can be any of the followings: “all” - all kind of members, “kicked” - kicked (banned) members only, “restricted” - restricted members only, “bots” - bots only, “recent” - recent members only, “administrators” - chat administrators only. Only applicable to supergroups and channels. Defaults to “recent”.
- 1
Server limit: on supergroups, you can get up to 10,000 members for a single query and up to 200 members on channels.
- 2
A query string is applicable only for “all”, “kicked” and “restricted” filters only.
- Returns
List of
ChatMember– On success, a list of chat members is returned.- Raises
ValueError – In case you used an invalid filter or a chat id that belongs to a user.
Example
# Get first 200 recent members app.get_chat_members("pyrogramchat") # Get all administrators app.get_chat_members("pyrogramchat", filter="administrators") # Get all bots app.get_chat_members("pyrogramchat", filter="bots")