Kurigram

raw JSON →
2.2.22 verified Mon Apr 27 auth: no python

An elegant, modern, and asynchronous Telegram MTProto API framework for Python, supporting both user and bot accounts. Current version is 2.2.22, with active development and regular releases.

pip install kurigram
error ModuleNotFoundError: No module named 'kurigram'
cause Kurigram is not installed or installed in a different environment.
fix
Run 'pip install kurigram' in your active Python environment.
error Cannot connect to Telegram. Make sure you have a working internet connection.
cause Invalid API ID/Hash or network issues.
fix
Obtain valid api_id and api_hash from my.telegram.org/apps and set them as environment variables or pass directly.
error TypeError: Client() got an unexpected keyword argument 'proxy'
cause Proxy configuration changed in newer versions of Kurigram.
fix
Use the 'proxy' parameter as a dict: Client('session', proxy=dict(hostname='127.0.0.1', port=8080)).
breaking Kurigram is a fork of Pyrogram with a different package name. Installing kurigram and pyrogram together may cause conflicts.
fix Uninstall pyrogram if you intend to use kurigram: pip uninstall pyrogram
deprecated Synchronous usage (e.g., Client().send_message without async) is deprecated and may break in future versions.
fix Use async/await and run with asyncio.run().
gotcha The default event loop on Windows may cause issues with asyncio. Use asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) before running.
fix Add asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) at the start of your script.

Basic async client that sends a message to 'Saved Messages'.

import asyncio
from kurigram import Client

async def main():
    app = Client("my_account", api_id=os.environ.get("API_ID", ""), api_hash=os.environ.get("API_HASH", ""))
    async with app:
        await app.send_message("me", "Hello from Kurigram!")

asyncio.run(main())