GramJS

messages.CheckChatInvite

Check the validity of a chat invite link and get basic info about it

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.messages.CheckChatInvite({
      hash: "B5MnlS34H1JKyBE71zZfo1",
    })
  );
  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.ChatInvite = await client.invoke(
    new Api.messages.CheckChatInvite({
      hash: "B5MnlS34H1JKyBE71zZfo1",
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
hashstringInvite hash in t.me/joinchat/hash

Result

ChatInvite

Possible errors

CodeTypeDescription
400INVITE_HASH_EMPTYThe invite hash is empty
400INVITE_HASH_EXPIREDThe invite link has expired
400INVITE_HASH_INVALIDThe invite hash is invalid

Can bots use this method?

No