Oct 9, 2022

Telegram MTProto API Framework

Pyrogram - Telegram MTProto API Framework for Python.

Pyrogram is a modern, elegant and asynchronous MTProto API framework. It enables you to easily interact with the main Telegram API through a user account (custom client) or a bot identity (bot API alternative) using Python. 

QuickStart

  1. Install Pyrogram with pip3 install -U pyrogram.
  2. Get your own Telegram API key from https://my.telegram.org/apps.
  3. Open the text editor of your choice and paste the following:
    1. import asyncio
      from pyrogram import Client 
      api_id = 12345
      api_hash = "0123456789abcdef0123456789abcdef" 
      async def main():
          async with Client("my_account", api_id, api_hash) as app:
              await app.send_message("me", "Greetings from **Pyrogram**!") 
      asyncio.run(main())
  4. Replace api_id and api_hash values with your own.
  5. Save the file as hello.py.
  6. Run the script with python3 hello.py
  7. Follow the instructions on your terminal to login.
  8. Watch Pyrogram send a message to yourself. 


Links: