getMe
Returns: UserOfficial docs ↗
A simple method for testing your bot's authentication token. Requires no parameters. Returns basic information about the bot in form of a User object.
Returns
On success, the User object is returned.
GramIO Usage
ts
// Verify the token and log the bot's identity
const me = await bot.api.getMe();
console.log(`Logged in as @${me.username} (ID: ${me.id})`);ts
// Read bot-specific capability flags
const me = await bot.api.getMe();
console.log(`Username: @${me.username}`);
console.log(`Can join groups: ${me.can_join_groups}`);
console.log(`Privacy mode off: ${me.can_read_all_group_messages}`);
console.log(`Supports inline: ${me.supports_inline_queries}`);
console.log(`Business integration: ${me.can_connect_to_business}`);
console.log(`Has main Web App: ${me.has_main_web_app}`);ts
// Use getMe for a startup health check before launching
async function start() {
const me = await bot.api.getMe();
console.log(`Bot @${me.username} is ready`);
await bot.start();
}
start();ts
// Conditionally register inline query handler only if the bot supports it
const me = await bot.api.getMe();
if (me.supports_inline_queries) {
bot.on("inline_query", (ctx) => ctx.answer([]));
}Errors
| Code | Error | Cause |
|---|---|---|
| 401 | Unauthorized: invalid token specified | The bot token is wrong or has been revoked — check BOT_TOKEN env var |
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after, use the auto-retry plugin |
Tips & Gotchas
- Call it once at startup, not repeatedly.
getMeis useful for a one-time token validation and capability check. The returned data doesn't change at runtime — cache it rather than calling on every update. - Bot-specific fields are only present in
getMeresponses. Fields likecan_join_groups,can_read_all_group_messages,supports_inline_queries,can_connect_to_business, andhas_main_web_appare only returned bygetMe— they are absent fromUserobjects you receive in updates. can_read_all_group_messages: truemeans privacy mode is disabled. By default bots only receive messages that mention them; disabling privacy mode lets the bot read all group messages. This is configured in @BotFather.- A failed
getMecall is always a token problem. If this call throws401 Unauthorized, the token is wrong or the bot was deleted. No other recovery is possible. is_botis alwaystrue. For the object returned bygetMe,is_botwill always betrue— you can use it to distinguish bots from regular users in other contexts.
See Also
- User — return type (with bot-only optional fields)
- getMyCommands — get commands registered for this bot
- getMyDefaultAdministratorRights — get the bot's default admin rights
- getMyName — get the bot's display name
- getMyDescription — get the bot's description