Telegram API_ID & API_HASH
To work with Telegram’s MTProto API (for userbots or custom clients), you need two unique identifiers: api_id and api_hash.
Step-by-Step Instructions
- Login: Go to my.telegram.org.
- Authentication: Enter your phone number in international format. You will receive a confirmation code via the Telegram app (not SMS).
- API Development: Click on the “API development tools” link.
- Create App: Fill out the form:
- App title: Any name you prefer.
- Short name: A simple alphanumeric string.
- Platform: Select any (e.g., Web or Android).
- Save: Click “Create application.” You will now see your
App api_idandApp api_hash.
Why do you need them?
Unlike the Bot API (used for @BotFather bots), these credentials allow you to:
- Build custom Telegram clients.
- Automate your personal account (Userbots).
- Analyze large amounts of public channel data.
- Manage account-level settings programmatically.
Security Warning
Keep your api_hash secret. If someone obtains your hash and phone number, they can gain full access to your account. Do not hardcode these values in public GitHub repositories.
Basic Example (Python/Telethon)
from telethon import TelegramClient
api_id = 12345
api_hash = 'your_api_hash_here'
with TelegramClient('session_name', api_id, api_hash) as client:
client.loop.run_until_complete(client.send_message('me', 'Hello from my blog!'))
XDesai
Who Am I?
Categories