Easy life :)

The client will handle most of the things for you:

  • Create an authorization key
  • Init the connection with app's info
  • Ensure datacenter choice
  • Easy download of files
  • ...

To create a new instance, use Kotlogram.getDefaultClient() method.

Execute a method

TelegramClient implements the TelegramApi interface for more convenience, you have 1 java method for each method of Telegram's API.
You can also call executeRpcQuery manually, and specify a dcId where to execute the method if you have to.

Queue a method

For more convenience, you can use the method queueMethodImmediate that is the same as MTProtoHandler's queueMethod but it'll subscribe automatically.

Get a downloader client

To avoid blocking your main client when uploading/downloading a file, it's strongly advised to use another connection, to do so, just use getDownloaderClient() to get a new instance of a client for the same account.

Download a user's photo


Download a chat's photo


Download a channel's photo


Download a file

client.downloadSync(inputLocation, size, partSize, outputStream);
  • inputLocation is an internal class of the library, it just contains a TLAbsInputFileLocation and the target dcId to know where to download the file.
  • size is the size in bytes of the file to download.
  • partSize optional parameter specifying the size of each parts to download (default is 512 KB)
  • outputStream stream to write in. A call to flush is made every 5 parts downloaded. This stream can be a ByteArrayOutputStream, FileOutputStream or whatever you'd like :)

Close client


Or, if you're have multiple clients running, or you plan to open a new one


Did this page help you?