shlogg · Early preview
Shakhzhakhan Maxudbek @xinitd

Sending Messages Via Telegram API With Python And Requests Library

Send messages via Telegram API using Python & Requests library. Use `https://api.telegram.org/bot<token>/sendMessage` with JSON body `{ "chat_id": chat_id, "text": "Hello World!" }`. Mark up with Markdown by adding `parse_mode": "Markdown"`.

Telegram provides API for sending messages to users as bot. You may send messages via HTTP POST method using any programming language. I use Python and Requests library.
URL address for sending message:

https://api.telegram.org/bot<token_from_botfather>/sendMessage

    
    

    
    




Body of message:

{
    "chat_id": chat_id,
    "text": "Hello World!"
}

    
    

    
    




If you want to markup your message with Markdown - add parse_mode parameter in body of JSON:

{
    "chat_id": chat_id,
    "text": "Hello World!",
    "parse_mode": "Markdown"
}

    
    

    
    




Her...