Telegram Bot API
🌐 Tiếng Việt

uploadStickerFile

Danh mục: Sticker · Bot API 10.3 · Tài liệu chính thức

Tải lên tệp sticker.

Giá trị trả về: Nếu thành công, trả về File.

Tham số

Tham sốKiểuBắt buộcMô tả
user_idIntegerCóID người dùng
stickerInputFileCóTệp sticker (InputFile hoặc file_id)
sticker_formatStringCóĐịnh dạng sticker: static, animated, video

Mô tả tham số chỉ là bản tóm tắt ngắn gọn; xem tài liệu chính thức để đọc toàn văn.

Ví dụ request

curl

curl -s "https://api.telegram.org/bot$TOKEN/uploadStickerFile" \
  -F user_id=123456789 \
  -F sticker_format=static \
  -F sticker=@sticker.png

Python

import requests

TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
    f"https://api.telegram.org/bot{TOKEN}/uploadStickerFile",
    data={
        "user_id": 123456789,
        "sticker_format": "static"
    },
    files={"sticker": open("sticker.png", "rb")},
    timeout=30,
)
print(resp.json())

JavaScript

import { readFile } from "node:fs/promises";

const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const form = new FormData();
form.append("user_id", "123456789");
form.append("sticker_format", "static");
form.append("sticker", new Blob([await readFile("sticker.png")]), "sticker.png");
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/uploadStickerFile`, { method: "POST", body: form });
console.log(await res.json());

Hướng dẫn từng bước: Cách tạo bot Telegram từ A đến Z: BotFather, token và tin nhắn đầu tiên