Tag: JSON

  • Get Telegram Bot ID

    1. Paste the following link in your browser. Replace with the API access token that you identified or created in the previous section: https://api.telegram.org/bot<API-access-token>/getUpdates?offset=0
    2. Send a message to your bot in the Telegram application. The message text can be anything. Your chat history must include at least one message to get your chat ID.
    3. Refresh your browser.
    4. Identify the numerical chat ID by finding the id inside the chat JSON object. In the example below, the chat ID is 123456789.
    {  
       "ok":true,
       "result":[  
          {  
             "update_id":XXXXXXXXX,
             "message":{  
                "message_id":2,
                "from":{  
                   "id":123456789,
                   "first_name":"Mushroom",
                   "last_name":"Kap"
                },
                "chat":{  
                   "id":123456789,
                   "first_name":"Mushroom",
                   "last_name":"Kap",
                   "type":"private"
                },
                "date":1487183963,
                "text":"hi"
             }
          }
       ]
    }
    

    If you have jq installed on your system, youcan also use the folowing command:

    curl https://api.telegram.org/bot<API-access-token>/getUpdates?offset=0 | jq -r .message.chat.id