Search code examples
telegramtelethonpyrogram

Get Telegram API_ID and API_HASH programmatically


I'm trying to figure out how to get my Telegram API_ID and API_HASH using either Telethon or Pyrogram but can't seem to find anything on the internet so far. In my program, a user can sign up to Telegram programmatically (without having to use their real phone number) but for them to be able to do anything an API_ID and API_HASH are required but then the phone verification site won't give code for that old number since it's one time only.

One solution that comes to mind, is scraping the telegram site and simulating the log in, then reading the code sent to the client and using that to scrape the API_ID and API_HASH from the web page but that sounds like too much work right now as i'd love a simpler approach.

I hope this is as clear as possible.

Thanks in advance.


Solution

  • While Telegram's MTPROTO API Credentials are bound to a specific account, they represent an Application like Telegram Android, Telegram Desktop or Telegram WebK/WebZ. You can use the same pair of API_ID and API_HASH across multiple applications.