GramJS

account.InitTakeoutSession

Intialize account takeout session

Example

const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.account.InitTakeoutSession({
      contacts: true,
      messageUsers: true,
      messageChats: true,
      messageMegagroups: true,
      messageChannels: true,
      files: true,
      fileMaxSize: 43,
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.account.Takeout = await client.invoke(
    new Api.account.InitTakeoutSession({
      contacts: true,
      messageUsers: true,
      messageChats: true,
      messageMegagroups: true,
      messageChannels: true,
      files: true,
      fileMaxSize: 43,
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
contactsflags.0?trueWhether to export contacts
messageUsersflags.1?trueWhether to export messages in private chats
messageChatsflags.2?trueWhether to export messages in legacy groups
messageMegagroupsflags.3?trueWhether to export messages in supergroups
messageChannelsflags.4?trueWhether to export messages in channels
filesflags.5?trueWhether to export files
fileMaxSizeflags.5?intMaximum size of files to export

Result

account.Takeout

Possible errors

CodeTypeDescription
420TAKEOUT_INIT_DELAY_XWait X seconds before initing takeout

Can bots use this method?

No

Channels

How to handle channels, supergroups, groups, and what's the difference between them.