IntroductionIntroduction about our broadcast API

Unlock the full potential of seamless broadcasting with our feature-rich API. Here's what you can do:

Ultra-Fast Broadcasting :

Deliver messages to over 100+ users in just 5 second. Keep your audience engaged with lightning-speed, real-time broadcasts.

Interactive Inline Keyboards :

Boost user engagement with customizable inline buttons, allowing effortless navigation and quick responses directly from your broadcast.

Flexible Message Formatting :

Supports both HTML and Markdown for rich-text formatting, giving you complete control over how your messages look and feel.

Instant New User Alerts :

Stay updated with real-time notifications when new users join your bot, helping you manage and grow your audience effectively.

Auto Remove Inactive Users

Effortlessly maintain an active and engaged user base by automatically identifying and removing inactive users from your bot. This feature ensures optimal performance and better resource allocation by keeping your audience list clean and relevant.

Tip 💡

Unlock premium features like unlimited broadcasts without ads, multiple admin notifications, a smoother experience, and more by upgrading to our Premium Membership!

Getting StartedGetting started with some easy steps

To get started with Teleservices Broadcast API, follow these steps:

Genarate Access Token

First, you need to generate an access token to authenticate your requests to the Teleservices API.

Access Token Example : Teleservice_80822da68dd77383f66661ac282f9ac0b3671fa2a028969ee616c983xxxxxxxxxxxxx

Generating Access Token
  1. To Genarate Access Token You need Your ot Token First From @BotFather.
  2. Now Grab Your Bot API Token And Go To @Tele_ServiceBot(Our Official Bot)
  3. Go To Bot
  4. Now Join Required Channel And Find And Click A Button
    Add Bots 🤖
  5. Now Bot Will Ask To Give Your Bot Api Token, Just Paste The Api Token And You Will Get Your Access Token Instantly.
Video Tutorial

Warning

Keep your Access Token safe and never share it with others. Unauthorized access to your data can occur if someone gains access to your token. Protect your information!

Read our privacy policy Here

Understanding Api EndpointLets make an idea about our Api endpoints

Before starting next steps you need to know our all public api Endpoints, all requirements and how it works.

API Endpoints :

an API to perform operations such as fetching, updating, or deleting data. Each endpoint represents a unique method to access or manipulate a resource, using HTTP methods like GET, POST, PUT, or DELETE.

For example, in Teleservice API, the broadcast endpoint allows bots to send messages to multiple users quickly and efficiently.

Available Api Endpoints

Adding Users :

Endpoint : https://api.teleservices.io/Broadcast/adduser/

Method : POST / GET

Parameters :

bot_token Your Bot Token Here. (Required)
access_token Your bot Access Token Genarated By our service (Required)
user_id Your Bot User Telegram Id (Required)
Send Broadcast :

Endpoint : https://api.teleservices.io/Broadcast/broadcast/

Method : POST

Parameters :

method Specifies the method to use for broadcasting (e.g., sendMessage, sendPhoto, sendVideo, etc.) (Required)
text The main message or content of the broadcast. Use this for plain text messages. (Required)
access_token The access token generated from the bot @Tele_ServiceBot, used to authenticate the API request.(Required)
bot_token The bot token you receive from BotFather after creating your bot. (Required)
admin The Telegram ID of the admin sending the broadcast status. (Required)
type Specifies the type of content you are broadcasting (e.g., text, photo, video, audio, etc.). (Required)
file_id The file ID of the media being sent (e.g., photo, video, audio). Leave this empty if you're sending text. (Optional)
caption If you are sending media (like a photo or video), you can include a caption for the media. (Optional)
parseMode Determines how to parse the message content. You can choose between html or Markdown for text formatting. (Optional)
disableWebPreview When set to true, disables link previews in the message. Default is false. (Optional)
protectContent Set to true to protect the content from being forwarded or saved by users. Default is false. (Optional)
ispin Set to true if you want the message to be pinned automatically. Default is false. (Optional)
Broadcast Forward Message :

Endpoint : https://api.teleservices.io/Broadcast/forward/

Method : POST

Parameters :

forward_chat_id Chat Id from where the post will be forwarded. (Required)
forward_message_id Message id of your post that will be forwarded. (Required)
ispin Set to true if you want the message to be pinned automatically. Default is false. (Optional)
forward Set to true if you want the message to be forword with forward ta and set false is don't wanna add forward Default is true(Optional)
Bot Statistics :

Endpoint : https://api.teleservices.io/Broadcast/status/

Method : GET

Parameters :

bot_username Bot username for which you want to featch details. (Required)

Code ExamplesCode examples for broadcast Api

In this section, you'll find practical code snippets and examples demonstrating how to use various Teleservice API endpoints effectively. These examples cover different programming languages and scenarios, including sending broadcasts, adding users to the database, and managing API credentials.

Each example is designed to help you understand how to implement API calls and handle responses, making it easier to integrate the Teleservice API into your applications. Whether you're working with JavaScript, Python, or other supported languages, these examples will guide you through the essential steps and best practices.

Lets Start With Popular Bot Coding Language BJS

BJS (Bot Java Script) is a synchronous scripting language for Telegram bots on Bots.Business (BB). It handles operations sequentially and uses callback commands for managing responses.

Adding Users :

Command : @@

BJS :


    
    
var url = "https://api.teleservices.io/Broadcast/adduser/";

   HTTP.post({
    url: url,
    headers: { "content-type": "application/json" },
        body: {
          access_token: "Your access Token Here",// generate from @tele_servicebot
          bot_token: bot.token,
          user_id: user.telegramid //You can use chat.id , to store both users and group chats
        },
})
Send Broadcast To Users :

Command : /broadcast

Wait For Answer : ON

Answer : Please Write or forward Your Message To Broadcast 📢

BJS :


    
    
var admin = user.telegramid; // replace with your admin id
var botLink = "@" + bot.name;

// Define the broadcast function outside of the try block
function broadcast(type, method, cap, fileid, forward_chat_id, forward_message_id) {
  var url = "https://api.teleservices.io/Broadcast/" + (type === "forward" ? "forward/" : "broadcast/");
  var botToken = bot.token;
  var accessToken = "Teleservice_aba0065847af1f83fee2d3ebf8d80a03a6a4f371ec1f0c8643c316fca7001617"; // Generate it from @Tele_ServiceBot

  HTTP.post({
    url: url,
    headers: { "content-type": "application/json" },
    body: {
      method: method,
      text: cap,
      access_token: accessToken,
      bot_token: botToken,
      admin: admin,
      type: type,
      file_id: fileid,
      caption: cap,
      parseMode: "HTML", // you can change it to Markdown
      disableWebPreview: true, // boolean value [true/false]
      protectContent: false, // pass true if you don't allow to forward/save message
      ispin: true, // pass true if you want to pin broadcast messages
      forward_chat_id: forward_chat_id || null,
      forward_message_id: forward_message_id || null,
      forward: true //pass false if want to remove forward tag while forwarding 
    }
  });
}

if (user.telegramid == admin) {
  try {
    var boarding = "";
    var caption = !request.caption ? boarding : boarding + " " + request.caption;

    // Handling forwarded media (photo, video, etc.)
    if (request.forward_from_chat) {
      // For forwarded messages from a chat
      broadcast("forward", "forwardMessage", null, null, request.forward_from_chat.id, request.forward_from_message_id);
      return;
    } else if (request.forward_from) {
      // For forwarded messages from a user
      broadcast("forward", "forwardMessage", null, null, request.chat.id, request.message_id);
      return;
    }

    // Handling regular messages and media
    if (request.photo && request.photo[0]) {
      broadcast("photo", "sendPhoto", caption, request.photo[0].file_id, null, null);
      return;
    }
    if (request.text) {
      broadcast("text", "sendMessage", request.text, null, null, null);
      return;
    }
    if (request.video) {
      broadcast("video", "sendVideo", caption, request.video.file_id, null, null);
      return;
    }
    if (request.audio) {
      broadcast("audio", "sendAudio", caption, request.audio.file_id, null, null);
      return;
    }
    if (request.document) {
      broadcast("document", "sendDocument", caption, request.document.file_id, null, null);
      return;
    }
    if (request.sticker) {
      broadcast("sticker", "sendSticker", null, request.sticker.file_id, null, null);
      return;
    }
    if (request.animation) {
      broadcast("animation", "sendAnimation", caption, request.animation.file_id, null, null);
      return;
    }
    if (request.voice) {
      broadcast("voice", "sendVoice", caption, request.voice.file_id, null, null);
      return;
    }
    if (request.video_note) {
      broadcast("video_note", "sendVideoNote", caption, request.video_note.file_id, null, null);
      return;
    }

  } catch (err) {
    Bot.sendMessage(err + " *Please Reach out @teleservices_support with Error Screenshot.*");
  }
} else {
  var notAdminText = "⚠️ You're not the admin of " + botLink + ".";
  Api.sendMessage({
    text: notAdminText,
    parse_mode: "html"
  });
}

Note

Don't forgot to replace the access token with your actual access token Teleservice_80822da68dd77383f66661ac282f9ac0b3671fa2a028969ee616c983xxxxxxxxxxxxx

Getting Bot Status :

Command : /status

BJS :


    
    
    if(!content){
var url = "https://api.teleservices.io/Broadcast/status/?bot_username=" +bot.name

HTTP.get({
url: url,
success: "/status"
})
}
else {
  var data = JSON.parse(content)
  var bot_name = bot.name
  var today_broadcast = data.Today_broadcast;
   var monthly_broadcast = data.Monthly_broadcast;
    var users = data.Users;
        var status_message =
            "📊 *" + bot_name + " Status:*\n\n" +
            "👤 *Total Users:* " + users + "\n" +
            "📅 *Today's Broadcasts:* " + today_broadcast + "\n" +
            "📆 *Monthly Broadcasts:* " + monthly_broadcast;
        // Send the status message as a reply       
         Api.sendMessage({
            chat_id: user.telegramid,
            text: status_message,
            parse_mode: "markdown",
            reply_to_message_id: message.message_id
             });
          }

Lets Start With Another popular coding languag TPY

TPY (Telegram Bot Python) is a custom Python-based framework designed specifically for creating and managing Telegram bots. It simplifies bot development by offering predefined commands, handlers, and features such as custom keyboards, inline buttons, and user-specific data storage. TPY provides unique functions like `Bot.runCommand()`, `User.saveData()`, and more, allowing developers to easily handle bot logic, manage conversations, and store data. While TPY is Python-based, it differs from regular Python, offering specialized functionalities tailored for Telegram bot development.

Adding Users

Command : /start

TPY :


     
accessToken = "Teleservice_80822da68dd77383f66661ac282f9ac0b3671fa2a028969ee616c983xxxxxxxxxxxxx" # Generate from @Tele_ServiceBot

token = Bot.info().token
data = {"bot_token": token, "access_token": accessToken, "user_id": message.chat.id}

# Send user data directly to the API
HTTP.post("https://api.teleservices.io/Broadcast/adduser/", json=data)

    
    
Sending Broadcast :

Command : /broadcast

TPY :


     

admin = "Your_Telegram_Id"
if str(message.chat.id) == admin:
    bot.replyText(u, "Please Write or forward Your Message To Broadcast 📢")
    Bot.handleNextCommand("/broad")
else:
    bot.replyText(u, "You are Not a Admin")
    
    
    

Command : /broad

TPY :


    
    
     
accessToken = "Teleservice_80822da68dd77383f66661ac282f9ac0b3671fa2a028969ee616c983xxxxxxxxxxxxx"#generate from @Tele_ServiceBot
 

try:
    def broadcast(type, method, cap, fileid, forward_chat_id=None, forward_message_id=None):
        url = "https://api.teleservices.io/Broadcast/"
        url += "forward/" if type == "forward" else "broadcast/"
        
        body = {
            "method": method,
            "text": cap,
            "access_token": accessToken,
            "bot_token": bot.token,
            "admin": message.chat.id,
            "type": type,
            "file_id": fileid,
            "caption": cap,
            "parseMode": "html",  # You can use both Markdown and HTML
            "disableWebPreview": True,
            "protectContent": True,  # Prevent users from saving or copying broadcast
            "ispin": False,  # Pass True to pin broadcast messages
            "forward": True # pass false if you don't want forward tag while forwarding
        }

        if type == "forward":
            body["forward_chat_id"] = forward_chat_id
            body["forward_message_id"] = forward_message_id

        # Send the request
        response = HTTP.post(url, json=body)

    boarding = ""
    caption = boarding if not message.caption else boarding + " Message = " + message.caption

    # Check for forwarded messages first
    if message.forward_from_chat:
        # Handle forwards from channels/groups
        broadcast("forward", "forwardMessage", None, None, message.forward_from_chat.id, message.forward_from_message_id)
    elif message.forward_from:
        # Handle forwards from users
        broadcast("forward", "forwardMessage", None, None, message.chat.id, message.message_id)
    
    # Now handle regular messages
    elif message.photo:
        broadcast("photo", "sendPhoto", caption, message.photo[-1].file_id)
    elif message.text:
        broadcast("text", "sendMessage", "Broadcast By Admin\nMessage = " + message.text, None)
    elif message.video:
        broadcast("video", "sendVideo", caption, message.video.file_id)
    elif message.audio:
        broadcast("audio", "sendAudio", caption, message.audio.file_id)
    elif message.document:
        broadcast("document", "sendDocument", caption, message.document.file_id)
    elif message.sticker:
        broadcast("sticker", "sendSticker", None, message.sticker.file_id)
    elif message.animation:
        broadcast("animation", "sendAnimation", caption, message.animation.file_id)
    elif message.voice:
        broadcast("voice", "sendVoice", caption, message.voice.file_id)
    elif message.video_note:
        broadcast("video_note", "sendVideo", caption, message.video_note.file_id)
    else:
        raise ReturnCommand

except Exception as e:
    bot.replyText(u, e)
    
    

Note

Don't forgot to replace the access token with your actual access token Teleservice_80822da68dd77383f66661ac282f9ac0b3671fa2a028969ee616c983xxxxxxxxxxxxx

Getting Status :

Command : /status

TPY :


     

     
# Send request to the API endpoint
url = f"https://api.teleservices.io/Broadcast/status/?bot_username={Bot.info().bot_username}"


try:
    # Fetch the data from the URL
    response = HTTP.get(url)
    response.raise_for_status()  # Check for HTTP errors
    
    # Parse the response into JSON-like structure
    get = bunchify(response.json())
    
    # Extract the required fields
    bot_name = get["Bot"]
    today_broadcast = get["Today_broadcast"]
    monthly_broadcast = get["Monthly_broadcast"]
    users = get["Users"]
    
    # Create the status message
    status_message = (
        f"📊 *{bot_name} Status:*\n\n"
        f"👤 *Total Users:* {users}\n"
        f"📅 *Today's Broadcasts:* {today_broadcast}\n"
        f"📆 *Monthly Broadcasts:* {monthly_broadcast}"
    )
    
    # Send the status message as a reply
    bot.sendMessage(chat_id=message.chat.id, text=status_message, parse_mode="Markdown", reply_to_message_id=message.message_id)

except Exception as e:
    # Send error message with the actual error
    error_message = f"❌ Error Occurred!\n
{str(e)}
" bot.replyText(chat_id=message.chat.id, text=error_message, parse_mode="HTML", reply_to_message_id=message.message_id)

Adding Inline Keyboard Lets learn how to add inline keyboard to make messages more attractive and engaging.

Using an inline keyboard in Telegram bot broadcasts enhances both the look and user engagement. It provides a clean, interactive interface with action buttons directly under the message, making it easier for users to respond quickly. This streamlined design not only improves the user experience but also encourages higher engagement, as users can take actions instantly without needing to type.

How To Add ?

  • Insert a single button:

    { [Button text] - t.me/LinkExample }
  • Insert multiple buttons in a single line:

    { [Button1 text] - t.me/LinkExample && [Button2 text] - t.me/LinkExample }
  • Insert multiple rows of buttons:

    { [Button1 text] - t.me/LinkExample

    [Button2 text] - t.me/LinkExample }
  • Insert A Share Button:

    { [Button text] - share: Text to share }
  • Insert a webapp inline button:

    {[Button text] - webapp:https://example.com}

Tip

Before broadcasting, test your inline keyboards to ensure they function correctly and provide a smooth user experience.

Report Bugs

Inline Examples

Here Some examples of inline button use

Insert a single button :
Hello this is a test message

{[Join Channel] - https://t.me/Teleservices_Api}

Insert multiple buttons in a single line:
Hello this is a test message

{[Join Channel] - https://t.me/Teleservices_Api && [Join Channel2] - https://t.me/Teleservices_Bots}

Insert multiple buttons in Multiple line:
Hello this is a test message

{[Join Channel] - https://t.me/Teleservices_Api

[Join Channel2] - https://t.me/Teleservices_Bots}

Insert a share button :
Hello this is a test message with share button

{[Share Me ] - share: Hello this is a a shared text from a bot}

Insert a webapp inline button :
Hello this is a test message with webapp inline button

{[Click here] - webapp:https://example.com}

Tip

You can combine multiple button types

Join Us On Telegram