Telegram Premium 與 Stars API
從您的應用程式、機器人或商店發送 Telegram Premium 與 Telegram Stars 禮物。簡潔的 REST API 採用 JSON 格式,單一 API 金鑰,訂單價格與網站相同並從餘額支付。
開始使用
- 請於帳戶頁面建立帳號並儲值餘額。
- 開啟「我的帳戶」後進入 API 頁面,建立您的 API 金鑰(僅顯示一次,請妥善儲存於伺服器)。
- 請在每個請求的X-Api-Key標頭中傳送此金鑰。
基礎 URL 與格式
所有請求均使用 HTTPS 與 JSON。成功回應格式為 { "ok": true, "data": ... },錯誤回應為 { "ok": false, "error": { "code", "message" } } 並包含穩定錯誤碼。
https://buytgpremium.com/api/v1
curl https://buytgpremium.com/api/v1/balance \
-H "X-Api-Key: btk_YOUR_KEY"
{ "ok": true, "data": { "credit": "120.00", "currency": "USD" } }端點
| 方式 | 路徑 | 功能說明 |
|---|---|---|
| GET | /balance | 您的餘額(美元) |
| GET | /products | Premium 方案期限與價格、Stars 數量區間與套組 |
| GET | /recipient?username= | 驗證用戶名類型:個人、頻道、群組、機器人或查無此號 |
| POST | /quote | 訂單金額與餘額是否足夠支付 |
| POST | /orders | 從餘額支付並建立贈禮訂單 |
| GET | /orders?limit=&batch= | 近期訂單(最多 100 筆) |
| GET | /orders/{code} | 依訂單代碼查詢單筆訂單 |
下單流程
Premium:產品 "premium",時長 3、6 或 12 個月,最多 10 個 username 作為收件人。Stars:產品 "stars",星星數量從 3,500 到 550,000,一個 username 作為收件人。總金額將立即從您的餘額中扣除,並為每位收件人建立一個訂單。
curl -X POST https://buytgpremium.com/api/v1/orders \
-H "X-Api-Key: btk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"product":"premium","months":12,"recipients":["alice","bob"]}'
{ "ok": true, "data": { "batch": "B-7KQ2-...", "total": "34.00", "currency": "USD",
"orders": [ { "code": "G-4MZ8-...", "product": "premium", "recipient": "alice", "months": 12,
"price": "17.00", "status": "completed" }, ... ] } }curl -X POST https://buytgpremium.com/api/v1/orders \
-H "X-Api-Key: btk_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"product":"stars","stars":5000,"recipient":"alice"}'錯誤代碼
| 代碼 | 說明 |
|---|---|
| 缺少 API 金鑰 / 無效的 API 金鑰 | 未提供金鑰、金鑰錯誤或已遭替換(401) |
| 無效輸入 / 無效收件者 | 請檢查產品、月數、星星或用戶名稱 (400) |
| recipient_not_user | 該用戶名是頻道、群組或機器人,或不存在 |
| insufficient_credit | 餘額不足訂單總額;請儲值 |
| network_error | 暫時性網路錯誤;您的餘額未變動,請重試 |
| rate_limited | 每個金鑰每分鐘超過 120 個請求(429,請參閱 Retry-After) |
限制與安全
- 每組金鑰每分鐘 120 次請求;每 10 分鐘 60 次收件者檢查。
- 每帳戶一組金鑰。替換時舊金鑰將立即失效。
- 請將金鑰保存在伺服器端。切勿置於網頁或行動應用中。