GramJS

account.InitTakeoutSession

Initialize 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: BigInt("-4156887774564"),
    })
  );
  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: BigInt("-4156887774564"),
    })
  );
  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 basic 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_%dWait %d seconds before initializing takeout.

Can bots use this method?

No

Channels, supergroups, gigagroups and basic groups

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