get_history

This example shows how to get the full message history of a chat, starting from the latest message.

import asyncio
from pyrogram import Client


async def main():
    app = Client("my_account")

    async with app:
        # "me" refers to your own chat (Saved Messages)
        async for message in app.get_chat_history("me"):
            print(message)


asyncio.run(main())