TUNGKAO API ドキュメント
API · telegram_login

Telegram でログイン

Telegram に自分で登録せずにサイトへ「Telegram でログイン」ボタンを追加。取得できる情報:name, username, photo

🕒 最終更新: タイ時間(UTC+07:00) · ✅ 既存のコードはそのまま動作

🤖 AI に連携コードを書かせる

このリンクを AI に渡すか(API 全体の Markdown)、ボタンを押すとプロンプトがコピーされ AI が開きます

https://app.tungkao.com/docs/api/telegram_login.md?lang=ja
https://api.tungkao.com/changelog/telegram_login.json

このリンクはこの API の更新を JSON で返します(key 不要・どのドメインからも可)。管理画面に「更新のお知らせ」として表示し、last_updated が変わったら「新着」を付けてください

ChatGPT ↗Claude ↗Gemini ↗Grok ↗

コピーして開く: AI ボタンでプロンプトが自動コピーされます。入力欄が空なら貼り付けてください

🔑 使うキー

加盟店ポータル(API key)で telegram_login キーを作成し、すべてのリクエストにこの header を送ります — 他サービスのキーはここでは使えません

Authorization: Bearer $TUNGKAO_KEY

🔗 ログインボタンのリンク

https://api.tungkao.com/oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https%3A%2F%2Fyourshop.com%2Fauth%2Fcallback&state=<RANDOM>

🛡️ すべて tungkao で完結:ユーザーは Telegram でログインした後、必ず先に tungkao に戻ります。本当にログインが成功したとき(またはログイン中のキャンセル時)だけあなたのリンクへ転送します — リンクを直接開いた人には tungkao のページしか表示されません。「会員」で 🌐 ドメイン(要認証)と ↩️ 戻りリンクを設定してください。

取得できる情報: name, username, photo

📋 手順

  1. プロバイダーのキーを作成し、「ログイン会員」でサイト名と戻り先 URI(https、完全一致)を設定します。
  2. ログインボタンはユーザーを /oauth/authorize へ送り、client_id(キー ID)、redirect_uri、state(毎回新しいランダム値をセッションに保存)を付けます。
  3. ユーザーが redirect_uri?code=…&state=… に戻る → state を確認 → サーバーが 2 分以内に POST /v1/login/token を呼び出す。
  4. data.user(例:7F3K9QX2-yourshopcom)を会員 ID に — 同じ人は常に同じ ID。

📡 API 呼び出し + コード例

POST/v1/login/token
curl -X POST https://api.tungkao.com/v1/login/token \
  -H "Authorization: Bearer $TUNGKAO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"from the redirect","redirect_uri":"https://yourshop.com/auth/callback"}'
GET/v1/login/users?limit=50
curl -X GET https://api.tungkao.com/v1/login/users?limit=50 \
  -H "Authorization: Bearer $TUNGKAO_KEY"

📖 Summary: using sign-in keys on several sites

ケースkey の設定(API Keys ページ)結果
One site, 2 keys of the same provider (e.g. website + app, both Google)Both keys: Combined (default)The same person gets the same user ID in both ✅
One site, 2 keys of the same provider, counted as separate accountsBoth keys: SeparateThe same person gets a different user ID on each key
2 sister sites sharing membersBoth keys: Group AA member has the same user ID on both sites ✅
2 unrelated sites that must not link membersBoth keys: SeparateDifferent user IDs, so the sites can't link their members ✅
A Google key and a LINE key (different providers)Any settingAlways different user IDs — they are different provider accounts
A key that already has sign-ins needs a different groupNot allowed (locked 🔒)Create a new key in the wanted group, so member IDs on your site never change

Set it on the “Sign-in user IDs between keys” card on the API Keys page before go-live (new keys default: Combined). Several keys may use the same domain.

完全な例(ボタン + コールバック + code 交換)

// npm i express express-session
import express from "express";
import session from "express-session";
import crypto from "node:crypto";

const KEY = process.env.TUNGKAO_KEY;            // API key (tk_live_…) server-side only
const CLIENT_ID = process.env.TUNGKAO_CLIENT_ID; // the key id (shown in the portal), not a secret
const REDIRECT = "https://yourshop.com/auth/callback"; // must match the registered URL exactly

const app = express();
app.use(session({ secret: process.env.SESSION_SECRET, resave: false, saveUninitialized: false, cookie: { secure: true, sameSite: "lax" } }));

// 1) your "Sign in" button links here
app.get("/auth/login", (req, res) => {
  req.session.state = crypto.randomBytes(24).toString("base64url");
  const u = new URL("https://api.tungkao.com/oauth/authorize");
  u.search = new URLSearchParams({ client_id: CLIENT_ID, redirect_uri: REDIRECT, state: req.session.state });
  res.redirect(u);
});

// 2) the user comes back with a code
app.get("/auth/callback", async (req, res) => {
  if (!req.query.state || req.query.state !== req.session.state) return res.status(400).send("state mismatch");
  delete req.session.state;
  if (req.query.error) return res.redirect("/login?cancelled=1");
  // 3) exchange the code for the user (within 2 minutes)
  const r = await fetch("https://api.tungkao.com/v1/login/token", {
    method: "POST",
    headers: { Authorization: `Bearer ${KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify({ code: req.query.code, redirect_uri: REDIRECT }),
  });
  const j = await r.json();
  if (!j.success) return res.status(400).send(j.error.message);
  req.session.user = j.data; // j.data.user = permanent member id, e.g. 7F3K9QX2-yourshopcom
  res.redirect("/");
});
app.listen(3000);
プロバイダーサービス取得できる情報
Googlegoogle_login名前、確認済みメール、写真
LINEline_login名前、写真、メール(同意時)
Facebookfacebook_login名前、写真、メール
TikToktiktok_login表示名、アバター(メールなし)
Discorddiscord_login名前、アバター、メール
Telegramtelegram_loginname, username, photo
X (Twitter)x_loginname, username, photo
Microsoftmicrosoft_loginname, email (Hotmail/Outlook)
GitHubgithub_loginname, email, avatar
Appleapple_loginpermanent member ID (no name or email in this mode)
Steamsteam_loginname, avatar and SteamID (no email)
Twitchtwitch_loginname, email, avatar
LinkedInlinkedin_loginname, email, photo
Kakaokakao_loginname, photo (email once Kakao approves it)
NAVERnaver_loginname, email, photo
Zalozalo_loginname, photo (no email)
Spotifyspotify_loginname, email, photo
Redditreddit_loginusername, avatar (no email)
GitLabgitlab_loginname, email, avatar
Robloxroblox_loginname, avatar (no email)
Epic Gamesepicgames_logindisplay name (no email)
Yahooyahoo_loginname, email, photo
Slackslack_loginname, email, photo
Amazonamazon_loginname, email

📚 使い方の例

例 1

A “Sign in with Telegram” button on your site

状況: A visitor taps Sign in with Telegram on your site

リクエスト
GET /oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https://yourshop.com/auth/callback&state=xyz

➡️ The user signs in with Telegram and returns to redirect_uri with a code and the same state

例 2

Exchange the code for the user (server side)

状況: Your server receives the code on the callback page (exchange within 2 minutes)

リクエスト
POST /v1/login/token
{
  "code": "<code from the callback>",
  "redirect_uri": "https://yourshop.com/auth/callback"
}
レスポンス例
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "provider": "telegram",
    "name": "Somchai",
    "is_new_user": true
  }
}

➡️ Use user as the member id in your database (stable per person)

例 3

A returning user signs in

状況: The same person signs in with Telegram again

レスポンス例
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "is_new_user": false,
    "login_count": 5
  }
}

➡️ Same user every time → look up the member and sign them in

例 4

One site, two Telegram keys (website + app)

状況: Separate keys for website and app, same members

➡️ Keep both keys “Combined” (default) before go-live → same user for the same person. Choose “Separate” to keep them apart

例 5

List members who signed in

状況: You want to browse or search members of this key

リクエスト
GET /v1/login/users?q=somchai&limit=50

➡️ Returns members with last sign-in time and count

例 6

The user cancels during sign-in

状況: The user cancels on the Telegram screen

➡️ Returns to redirect_uri with error instead of code; show a retry button

💡 その他

📜 この API の更新履歴

  1. 追加 タイ時間(UTC+07:00)
    🖼️ Show your own logo on the sign-in page, per key (50×50, auto-cropped and resized). Billed monthly: buy 1–11 months or 1 / 2 / 3 years. Hiding the credit now offers the same periods.
  2. 改善 タイ時間(UTC+07:00)
    🌐 The sign-in page and the phone-model sign-in help now support all 10 API languages (th, en, lo, my, zh-CN, ko, ja, vi, km, id), picked from the device language or &lang= on the sign-in link, with a language switcher at the bottom
  3. 改善 タイ時間(UTC+07:00)
    📱 The sign-in help page now names the visitor's exact phone model (e.g. Galaxy S24 Ultra), adds model search, and refreshes the Android model list daily from Google Play — new models get a “New” badge
  4. 追加 タイ時間(UTC+07:00)
    📱 Step-by-step “sign-in doesn't continue” help by phone brand and model (iPhone, iPad, Samsung, Huawei, HONOR, Xiaomi, OPPO, vivo, realme, OnePlus, Pixel, other Android), with the brand guessed from the device and a link from the sign-in page
  5. 追加 タイ時間(UTC+07:00)
    Sign-in: choose whether user IDs are combined or separate between keys (whole account / group A–E / separate). New keys default to combined; keys that already have sign-ins stay in their group
  6. 追加 タイ時間(UTC+07:00)
    API update announcements by webhook: new api.update event (opt in per key on the key card; off by default)
  7. 改善 タイ時間(UTC+07:00)
    📣 Notice: phones with two copies of a provider's app (app clone / Dual Messenger / dual apps) cannot sign in through the clone — confirmed for LINE (unknown-error dialog). The sign-in page now warns users for every app-based provider, and the sign-in link accepts &app=browser / &app=native
  8. 追加 タイ時間(UTC+07:00)
    Mobile sign-in that jumps to the provider app (X, Discord, LINE…): two per-key options — A stay in the same browser (Android, recommended), B the original tab signs in on return (tk-login.js). Desktop is unaffected
  9. 追加 タイ時間(UTC+07:00)
    Ready-made sign-in buttons: /static/tk-login.js restyles your existing buttons with real logos and colours (add data-tk-login)
  10. 改善 タイ時間(UTC+07:00)
    A bad sign-in link (client_id / redirect_uri / state) now shows a page with the reason and the fix instead of redirecting home
  11. 追加 タイ時間(UTC+07:00)
    error.user_message: ready-to-show text for end users on outages, no credits or key problems (white-label keys omit tungkao.com)
  12. 追加 タイ時間(UTC+07:00)
    GET /status:サービス別の API ステータス(キー不要)
  13. 追加 タイ時間(UTC+07:00)
    キーのオン/オフと状態変更時刻 + 1 サイトにつきサービスごとに 1 キー
  14. 改善 タイ時間(UTC+07:00)
    API v1 を恒久固定(追加のみ)+ X-Tungkao-Api-Version header + 12 か月前の廃止予告
  15. ドキュメント タイ時間(UTC+07:00)
    API ごとのドキュメントと AI リンク(10 言語)
  16. セキュリティ タイ時間(UTC+07:00)
    API キーごとのドメイン認証(1 キー = 1 サイト)— 既存キーはそのまま動作
  17. 追加 タイ時間(UTC+07:00)
    任意の HMAC リクエスト署名 — オンにしなければ変化なし
  18. 追加 タイ時間(UTC+07:00)
    API キーの期限・期限前通知・更新 — キー文字列は変わらない
  19. 追加 タイ時間(UTC+07:00)
    全サービスに test モードキー(模擬・無料)

✅ 既存のコードはそのまま動作

🛡️ 安定性の約束:一度つなげばずっと動く

🚦 システム状況(GET /status)

API が正常かいつでも確認できます(キー不要)

GET https://api.tungkao.com/status

curl https://api.tungkao.com/status
{
  "success": true,
  "data": {
    "status": "ok",
    "services": [
      { "id": "slip_verify", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "slip_deposit", "status": "ok", "routes": ["ok", "ok", "busy"] },
      { "id": "login", "status": "ok" },
      { "id": "telegram", "status": "ok" },
      { "id": "discord", "status": "ok" },
      { "id": "email", "status": "busy" },
      { "id": "crypto", "status": "ok" },
      { "id": "core", "status": "ok" }
    ],
    "paused": [],
    "updated_at": "2026-11-14T12:00:00.000Z"
  }
}

🏷️ TUNGKAO クレジット表記の要件

Powered by TUNGKAO