Skip to content

getChatAdministrators

Use this method to get a list of administrators in a chat, which aren't bots. Returns an Array of ChatMember objects.

Parameters

chat_idIntegerStringRequired
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

Returns

On success, an array of ChatMember objects is returned.

GramIO Usage

ts
// List all human administrators in the current chat
bot
.
command
("admins", async (
ctx
) => {
const
admins
= await
bot
.
api
.
getChatAdministrators
({
chat_id
:
ctx
.
chat
.
id
,
}); const
names
=
admins
.
map
((
a
) =>
a
.
user
.
first_name
).
join
(", ");
await
ctx
.
send
(`Administrators: ${
names
}`);
});
ts
// Check if a specific user is an admin
async function 
isAdmin
(
chatId
: number | string,
userId
: number) {
const
admins
= await
bot
.
api
.
getChatAdministrators
({
chat_id
:
chatId
});
return
admins
.
some
((
a
) =>
a
.
user
.
id
===
userId
);
}
ts
// Verify whether the bot itself has admin rights
bot
.
command
("amiadmin", async (
ctx
) => {
const
me
= await
bot
.
api
.
getMe
();
const
admins
= await
bot
.
api
.
getChatAdministrators
({
chat_id
:
ctx
.
chat
.
id
,
}); const
isBotAdmin
=
admins
.
some
((
a
) =>
a
.
user
.
id
===
me
.
id
);
await
ctx
.
send
(
isBotAdmin
? "I am an admin!" : "I am not an admin.");
});
ts
// Direct API call for a public channel by username
const 
admins
= await
bot
.
api
.
getChatAdministrators
({
chat_id
: "@durov",
});
console
.
log
(`${
admins
.
length
} admin(s) found`);

Errors

CodeErrorCause
400Bad Request: chat not foundInvalid or inaccessible chat_id — verify the chat ID and ensure the bot is a member
400Bad Request: method is available for supergroup and channel chats onlyCalled on a private chat or basic group — only works on supergroups and channels
403Forbidden: bot is not a member of the channel chatBot was removed from the chat or never joined
429Too Many Requests: retry after NRate limit hit — check retry_after, use the auto-retry plugin

TIP

Use GramIO's auto-retry plugin to handle 429 errors automatically.

Tips & Gotchas

  • Bots are excluded from the results. The method returns only human administrators. To check if the bot itself has admin rights, call getMe() and compare the bot's ID against the returned list.
  • Works on supergroups and channels only. Calling this on a private chat or a basic group raises an error. Always check the chat type first.
  • Results may be cached briefly. Telegram may serve a slightly stale admin list; don't rely on it for instant permission checks after a promotion.
  • The creator has status: "creator". Other admins have status: "administrator". Filter by status to distinguish the owner from regular admins.
  • @username strings work for public chats. Pass "@channelusername" for public supergroups and channels — no need to look up the numeric ID.
  • Custom titles are available. For ChatMemberAdministrator, the custom_title field shows the admin's display title if one was set.

See Also