Skip to content

Instantly share code, notes, and snippets.

@alexunderboots
Forked from SanariSan/readme.md
Created May 24, 2025 04:39
Show Gist options
  • Select an option

  • Save alexunderboots/a5d994d9592f2313ef1bf0e414b65af1 to your computer and use it in GitHub Desktop.

Select an option

Save alexunderboots/a5d994d9592f2313ef1bf0e414b65af1 to your computer and use it in GitHub Desktop.
Telegram HTTP bot API via CURL | Send text, photos, documents, etc.

Here are some examples on how to use Telegram bot api via curl

Environment variables used, feel free to replace with bare text

  • Create a bot using @BotFather, get it's token
  • Start conversation with bot
  • Go to @getmyid_bot and obtain your account id

Now you can send messages to yourself in a chat with bot:

Send document from disk

curl -X POST -H "Content-Type:multipart/form-data" -F document=@"path/to/some.file" "https://api.telegram.org/bot$TOKEN/sendDocument?chat_id=$CHAT_ID"

Create qr code from string, pipe stdout to curl, send it as an image

qrencode -s 6 -o - "Some text to encode" | curl -X POST -H "Content-Type:multipart/form-data" -F photo=@- "https://api.telegram.org/bot$TOKEN/sendPhoto?chat_id=$CHAT_ID"

More message types could be found here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment