Skip to content

HowTo: Get Telegram API_ID & API_HASH

Amin Mahmoudi edited this page Sep 25, 2024 · 2 revisions

HowTo: Get Telegram API_ID & API_HASH

If you want to use the Pyrogram session in the MasterCryptoFarmBot, you need to get the API_ID and API_HASH from the Telegram API.

If you are using TgWebInitData, you don't need to get the API_ID and API_HASH.

Read More about Adding Accounts

Telegram API_ID and API_HASH are required to create a Pyrogram session. Telegram will provide you with the API_ID and API_HASH when you create a new application on the Telegram website. This is necessary to use the Telegram API.

📝 Steps to Get API_ID and API_HASH

  1. 🌐 Open the Telegram website: Open the Telegram website in your browser.

  2. 🔑 Log in to your Telegram account: Log in to your Telegram account using your phone number.

  3. 🔧 Access API development tools: Click on the API development tools link.

  4. ➕ Create a new application: Click on the Create application button.

  5. 📝 Fill out the form: Complete the form with the required details such as the application name, short name, and platform.

  6. 🔐 Get the API_ID and API_HASH: After creating the application, you will receive the API_ID and API_HASH. Save these details in a safe place.

⚙️ How to Use API_ID and API_HASH

After getting the API_ID and API_HASH, you need to add them to the config.py file in the MasterCryptoFarmBot folder. If you don't have the config.py file, you can create one by copying the config.py.sample file and renaming it to config.py. Don't remove the config.py.sample file, it is required for the update process.

Open the config.py file and edit the API_ID and API_HASH in the following format:

"telegram_api": {
    "api_id": YOUR_API_ID,
    "api_hash": "YOUR_API_HASH",
}

Replace YOUR_API_ID and YOUR_API_HASH with the API_ID and API_HASH you received from the Telegram website.

That's it! You have successfully obtained the API_ID and API_HASH from the Telegram API. You can now use them to create a Pyrogram session for the MasterCryptoFarmBot.

"telegram_api": {
    "api_id": 1234567,
    "api_hash": "0123456789abcdef0123456789abcdef",
}

📚 References