start()

async Client.start()

Start the client.

Usable by Users Bots

This method connects the client to Telegram and, in case of new sessions, automatically manages the authorization process using an interactive prompt.

Parameters:
  • use_qr (bool, optional) – Use QR code authorization instead of the interactive prompt. For new authorizations only. Defaults to False.

  • except_ids (List of int, optional) – List of already logged-in user IDs, to prevent logging in twice with the same user.

Returns:

Client – The started client itself.

Raises:

ConnectionError – In case you try to start an already started client.

Example

from pyrogram import Client

app = Client("my_account")


async def main():
    await app.start()
    ...  # Invoke API methods
    await app.stop()


app.run(main())