ptgb
A complete Telegram Bot API client for Dart

Sending Media

Part of the API Reference.

sendPhoto

Future<Json> sendPhoto(
    Object chatId,
    InputFile photo, {
    String? businessConnectionId,
    int? messageThreadId,
    String? caption,
    ParseMode? parseMode,
    List<Json>? captionEntities,
    bool? showCaptionAboveMedia,
    bool? hasSpoiler,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
  }) async =>

Sends a photo. [photo] accepts a file_id, a URL, or a local upload via [InputFile.path]/[InputFile.bytes].

sendAudio

Future<Json> sendAudio(
    Object chatId,
    InputFile audio, {
    String? businessConnectionId,
    int? messageThreadId,
    String? caption,
    ParseMode? parseMode,
    List<Json>? captionEntities,
    int? duration,
    String? performer,
    String? title,
    InputFile? thumbnail,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
  }) async =>

Sends an audio file that Telegram will display with a music player UI. Use [sendVoice] instead for voice-message-style recordings, or [sendDocument] for arbitrary audio files you don’t want played inline.

sendDocument

Future<Json> sendDocument(
    Object chatId,
    InputFile document, {
    String? businessConnectionId,
    int? messageThreadId,
    InputFile? thumbnail,
    String? caption,
    ParseMode? parseMode,
    List<Json>? captionEntities,
    bool? disableContentTypeDetection,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
  }) async =>

Sends a general file/document of any type.

sendVideo

Future<Json> sendVideo(
    Object chatId,
    InputFile video, {
    String? businessConnectionId,
    int? messageThreadId,
    int? duration,
    int? width,
    int? height,
    InputFile? thumbnail,
    String? caption,
    ParseMode? parseMode,
    List<Json>? captionEntities,
    bool? showCaptionAboveMedia,
    bool? hasSpoiler,
    bool? supportsStreaming,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
  }) async =>

Sends a video that Telegram can play inline in the chat.

sendAnimation

Future<Json> sendAnimation(
    Object chatId,
    InputFile animation, {
    String? businessConnectionId,
    int? messageThreadId,
    int? duration,
    int? width,
    int? height,
    InputFile? thumbnail,
    String? caption,
    ParseMode? parseMode,
    List<Json>? captionEntities,
    bool? showCaptionAboveMedia,
    bool? hasSpoiler,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
  }) async =>

Sends an animation (GIF or silent, looping MP4).

sendVoice

Future<Json> sendVoice(
    Object chatId,
    InputFile voice, {
    String? businessConnectionId,
    int? messageThreadId,
    String? caption,
    ParseMode? parseMode,
    List<Json>? captionEntities,
    int? duration,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
  }) async =>

Sends a voice-message-style audio clip (displayed with a waveform in the Telegram UI). The file must be an .ogg encoded with the OPUS codec, or another format Telegram can automatically convert.

sendVideoNote

Future<Json> sendVideoNote(
    Object chatId,
    InputFile videoNote, {
    String? businessConnectionId,
    int? messageThreadId,
    int? duration,
    int? length,
    InputFile? thumbnail,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
  }) async =>

Sends a round “video note” message (the circular video bubbles seen in Telegram chats). Telegram only supports square, i.e. width == height, video notes.

sendMediaGroup

Future<List<Json>> sendMediaGroup(
    Object chatId,
    List<InputMedia> media, {
    String? businessConnectionId,
    int? messageThreadId,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
  }) async {

Sends an album of 2-10 photos/videos/documents/audio files grouped together as a single message using a list of [InputMedia] items.

sendPaidMedia

Future<Json> sendPaidMedia(
    Object chatId,
    int starCount,
    List<InputPaidMedia> media, {
    String? businessConnectionId,
    String? payload,
    String? caption,
    ParseMode? parseMode,
    List<Json>? captionEntities,
    bool? showCaptionAboveMedia,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
  }) async {

Sends paid media (photos/videos) that chat members must pay [starCount] Telegram Stars to unlock. Star proceeds are credited to the channel's balance if [chatId] is a channel, or to the bot's balance otherwise.

sendLivePhoto

Future<Json> sendLivePhoto(
    Object chatId,
    InputFile photo,
    InputFile video, {
    String? businessConnectionId,
    int? messageThreadId,
    String? caption,
    ParseMode? parseMode,
    List<Json>? captionEntities,
    bool? showCaptionAboveMedia,
    bool? hasSpoiler,
    int? duration,
    int? width,
    int? height,
    bool? disableNotification,
    bool? protectContent,
    bool? allowPaidBroadcast,
    String? messageEffectId,
    ReplyParameters? replyParameters,
    ReplyMarkup? replyMarkup,
    int? receiverUserId,
    String? callbackQueryId,
  }) async =>

Sends a "live photo" — a still [photo] paired with a short [video] clip that plays when the recipient taps it.

If [receiverUserId] is set (together with [callbackQueryId], from a callback query the guest triggered), the message is sent as an ephemeral message visible only to that user — see [editEphemeralMessageText] and friends for editing it afterwards.