Telegram API

Send Telegram messages securely via API. Perfect for notifications, alerts, and automated messaging.

Overview

API Plugin's Telegram API provides a secure way to send messages through Telegram. Ideal for sending notifications, alerts, updates, and automated messages to users, groups, or channels.

Key benefits include:

  • Secure message sending
  • Channel & group support
  • Rich message formatting
  • File attachment support
  • Automated notifications
  • Easy integration
  • Reliable delivery

How to Setup

We assume you have signed up on API Plugin and are logged into the dashboard.

  1. Create a Telegram Bot:

    • Open Telegram and search for "@BotFather"
    • Send "/newbot" command
    • Follow instructions to create your bot
    • Copy the bot token provided
  2. Configure API:

    • Go to API Plugin marketplace
    • Select Telegram API
    • Input your bot token
    • Create API endpoint

Available Endpoints

  1. Send Message
POST /v1/{appId}/{token}/message

Parameters:

  • chat_id (required): Recipient's chat ID
  • text (required): Message text
  • parse_mode: Message format (HTML/Markdown)

Example Request:

{
    "chat_id": "123456789",
    "text": "Hello from API Plugin!",
    "parse_mode": "HTML"
}
  1. Send File
POST /v1/{appId}/{token}/file

Parameters:

  • chat_id (required): Recipient's chat ID
  • file_url: URL of file to send
  • caption: File caption
  1. Get Updates
GET /v1/{appId}/{token}/updates

Returns recent bot updates, including messages and chat IDs.

Message Formatting

  1. HTML Format
<b>Bold text</b>
<i>Italic text</i>
<code>Monospace text</code>
<a href="http://example.com">Link text</a>
  1. Markdown Format
_Bold text_
_Italic text_
`Monospace text`
[Link text](http://example.com)

Example Code

// Send message
const response = await fetch('/v1/{appId}/{token}/message', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        chat_id: '123456789',
        text: '<b>Important Update!</b>\nSystem status: Online',
        parse_mode: 'HTML',
    }),
});

// Get updates
const updates = await fetch('/v1/{appId}/{token}/updates');
const chatIds = updates.data.map((update) => update.message.chat.id);