Replace with token, leave the 'bot' part in the URL.
Replace with your chat ID, example: -1234567890.
You may need to put -100 first, like: -1001234567890, depending on chat/group/channel type.
You can also use &parse_mode=html instead of markdown.
Bash:
# send photo with caption (GIF will not be animated in this mode)
curl -X POST https://api.telegram.org/bot<token>/sendPhoto \
-F chat_id=-<chat> \
-F photo=@./KBOX_loop.gif \
-F caption="*Hello*, _channel_!" \
-F parse_mode=MarkdownV2
# send GIF with caption (GIF will be animated)
curl https://api.telegram.org/bot<token>/sendDocument \
-F chat_id=-<chat> \
-F document=@./KBOX_loop.gif \
-F caption="*Hello*, _channel_!" \
-F parse_mode=MarkdownV2
Python:
import requests
files = {
'chat_id': (None, "-1234567890"),
'document': open('./KBOX_loop.gif', 'rb'),
'caption': (None, '*Hello*, _channel_!'),
'parse_mode': (None, 'MarkdownV2'),
}
response = requests.post(
f"https://api.telegram.org/botABCDEFGH:IJKLMNOP/sendDocument",
files=files
)