Is it feasible to extract a user’s ID solely by providing their username? I am interested in incorporating a feature into my bot where, given the username of another user, it can display that user’s unique ID. In other words, does the Telegram API allow for such functionality or is there an alternative method to achieve this? I would appreciate any insights into how to implement this feature using the available API capabilities.
hey, i dont think its doable without the user actually interactng with the bot. api only shows info for users in the same chat, so if they’re not present, you cant get their id.
In my experience, the Telegram API does not permit retrieving a user’s ID solely based on their username due to privacy considerations. The API is structured to allow access only when the user has directly interacted with the bot or is part of a mutual chat, which means the unique ID is available only after an initial engagement. While there are unofficial methods circulating online, these approaches are not endorsed by Telegram and may violate their policies. It is advisable to have users interact with the bot to securely gain access to their data.
During my time working with Telegram bots, I’ve found that the platform strictly enforces privacy measures which prevent direct access to user IDs via a username alone. In my projects, this limitation has meant designing an initial engagement or registration process where the user interacts with the bot. This not only ensures compliance with Telegram’s policies but also upholds the privacy of end users. My experience indicates that when considering alternatives, it’s important to work within the available API functionalities to avoid creating vulnerabilities or violating the platform’s regulations.
hey, you cant get a user id using just a username. the telegram api only shows id info if the user interacts with your bot. you should design a flow that enforces user engagement to avoid any privacy issues.