Get TELEGRAM Channel/Group ID
Asked Answered
I

9

7

Let's say, I've joined TELEGRAM group...

I am just a typical member of GROUP (and thus, cant use any bots there.. ?) so, I am unable to find out the way, how to get GROUP ID.

Instigate answered 31/7, 2017 at 10:57 Comment(1)
there are lots of ways to do so. simplest one: download plus messenger which is a fork of telegram. it shows every channel's id in the about page of that channelProvincialism
T
5

via code:

If you are a member of a group, you should receive updates from that group when ever there is any activity from that group. The updates will contain a chats list-element from which you can get a Channel which has the following relevant fields:

id: group_id, 
title: "the_group_title", 
username: "group_username"
Townsfolk answered 8/8, 2017 at 13:32 Comment(3)
that is true for bots, using getUpdates, but how about regular user? i dont have bots in those groups..Instigate
i'm not referring to bots, i'm referring to a simple Telegram API client , which receives updates from Telegram Servers via codeTownsfolk
It would probably better if you show a bit of code?Spurling
M
25

New Update
Just Simply Forward a message from your channel to This Bot: (https://telegram.me/getidsbot)

Update
1: Goto (https://web.telegram.org)
2: Goto your Gorup and Find your link of Gorup(https://web.telegram.org/#/im?p=g154513121)
3: Copy That number after g and put a (-) Before That -154513121
4: Send Your Message to Gorup bot.sendMessage(-154513121, "Hi")
I Tested Now and Work like a Charm

Node.js:
Try using TelegramBot#getChat():

bot.getChat("@channelusername").then(function(chat) {
    // 'chat' is a Chat object
    console.log(chat.id);
});

See API getChat() method and Chat object.

Hope that helps.

Movement answered 8/8, 2017 at 20:47 Comment(3)
have you read question at all? forwarding a message doent return id of that group.cna you give a screenshot where the group id is shown?Instigate
i cant find that link... links of groups end with like: ../im?p=@GroupSlugNameInstigate
awesome solution with that web telegram, thanks a lot !Hippocrates
F
12

There is a unofficicl Plus Messenger client for Android users, and you can see ID in group/channel info.

Supergroup and Channel will looks like 1068773197, which is -1001068773197 for bots (with -100 prefix).

If you just want to obtain channel/user ID, forward message to @RawDataBot.

Futures answered 31/7, 2017 at 11:56 Comment(2)
I see CHANNEL ID's , but not GROUP ids (under their logos).Instigate
also, read this - #45414521Instigate
P
6

there are lots of ways to do so.

simplest one: download plus messenger which is a fork of telegram. it shows every channel's id in the about page of that channel.

https://play.google.com/store/apps/details?id=org.telegram.plus&hl=en

thanks to @Sean:

Supergroup and Channel will looks like 1068773197, which is -1001068773197 for bots (with -100 prefix).


Above method works for channels, for groups you may use this method:

Just forward a single message from that chat to @RawDataBot. it will reply you with a json data containing chatid.

Provincialism answered 31/7, 2017 at 11:25 Comment(7)
I saw Channel ID under it's logo (after long-pressing the logo), but cant find GROUP IDInstigate
for groups you may use bots like @RawDataBot that dear Sean has mentioned.Provincialism
how can i add @RawDataBot to XYZ group ? (in that XYZ group i am not an admin, just a memeber).Instigate
No need for that. Just forward a single message from that chat to this bot.it will send you json data containing chatid.Provincialism
Unfortunately, @RawDataBot incorrectly returns CHAT_ID . please, make a screenshot how you get that, and i'll reward your answer.. I have forwarded several different messages from different groups, but i see the same CHAT_IDs on it's all answers.Instigate
You're right it's the id of the chat of user with bot.Provincialism
and have not been clear my question? I asked same and same, how to get ID of chat of group i am joined?Instigate
T
5

via code:

If you are a member of a group, you should receive updates from that group when ever there is any activity from that group. The updates will contain a chats list-element from which you can get a Channel which has the following relevant fields:

id: group_id, 
title: "the_group_title", 
username: "group_username"
Townsfolk answered 8/8, 2017 at 13:32 Comment(3)
that is true for bots, using getUpdates, but how about regular user? i dont have bots in those groups..Instigate
i'm not referring to bots, i'm referring to a simple Telegram API client , which receives updates from Telegram Servers via codeTownsfolk
It would probably better if you show a bit of code?Spurling
M
4

As of my experience ,there are two popular libraries,

python-Telethon            --->Telegram Client Library(uses api_id,api_hash) 
python-Telegram-bot        ---->Telegram Bot (uses api token)

There are lot of ways to get the user_id ,group_id,channel_id . To get the these ids use Telethon client library

from telethon import TelegramClient,sync
api_id="xxx" #get from telegram website
api_hash="yyy" #get from telegram website
client=TelegramClient(session_object,api_id,api_hash) 
client.start()
#To get the channel_id,group_id,user_id
for chat in client.get_dialogs():
    print('name:{0} ids:{1} is_user:{2} is_channel{3} is_group:{4}'.format(chat.name,chat.id,chat.is_user,chat.is_channel,chat.is_group))

That is all about, it will print name and id of channel,group,user. Also, it will check wheather the id is belong to channel or group or user

generally, Channel id starts with negrative(eg:-1001109500936) starts with (-100) group id is normal and starts with negative user id starts with positve

Another way is to use 'plus messanger app' To see all the group,channel,user id Cheers

Another Simple Way,

client=TelegramClient(session,api_id,api_hash)
client.start()
destination_entity_name="Type User(may be bot) or group or channel name"
entity=client.get_entity(destination_entity_name)
print(entity.stringify()) #All paratmeters
print(entity.id)       #user(bot also considered as user) or group
Marconigraph answered 28/3, 2019 at 6:43 Comment(0)
M
1

That should be obtainable using tg-messenger-cli: https://github.com/vysheng/tg I haven't had time to try it out yet but friend has made some automated messages for his daughter. Should be quite versatile.

Merrileemerrili answered 31/7, 2017 at 11:2 Comment(1)
i can't install stan-alone server on my pc to get the ID' :( i just want a simple way, like other suggested. however, may thanks!Instigate
I
1

After hours spent, I was able to find the ID of GROUPS using CuteGram app.

Open group there, and click "COPY" icon, that opens a folder, and in the address you will see the ID.

Instigate answered 9/8, 2017 at 12:31 Comment(1)
github.com/Aseman-Land/Cutegram is a working link, original is broken.Inconsumable
S
0

Every chat room has a Chat ID number attached to it. It doesn’t matter if it’s private or public nor how many people are involved.

You can access Telegram by using a browser, the mobile app or the desktop app. From there on, you can contact a bot to find the chat ID of your channel, group or personal chat. Here’s how to do it:

Method 1 - Use the @jsondumpbot

  1. Click on @jsondumpbot or search for JSON Dump Bot on Telegram.
  2. Forward a message from that channel to the JsonDumpBot telegram bot. You should see something like:

enter image description here

That's the of channel/group you forwarded from

Method 2 - Use Telegram Web

  1. Go to https://web.telegram.org
  2. Click on your channel
  3. Look at the URL and find the part that looks like c12112121212_17878787878787878
  4. Remove the underscore and after c12112121212
  5. Remove the prefixed letter 12112121212
  6. Prefix with a -100 so -10012112121212
  7. That’s your channel id.
Spurling answered 1/3, 2023 at 4:51 Comment(0)
O
-1

Invite your bot to your group

and use ur bot to text /myid

then use the GetUpdates api, you shall have your group ID

Omura answered 14/12, 2018 at 6:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.