TUNGKAO Tài liệu API
Bấm nút rồi chọn “Lưu dưới dạng PDF”

TUNGKAO API

Đăng nhập bằng Steam

API v1 · Cập nhật lần cuối: Giờ Thái Lan (UTC+07:00)

https://tungkao.com · https://api.tungkao.com/docs

Theo điều khoản, trang dùng dịch vụ phải hiển thị “Powered by TUNGKAO” (hoặc “Secured by TUNGKAO” cho đăng nhập/thanh toán) liên kết tới https://tungkao.com

API · steam_login

Đăng nhập bằng Steam

Thêm nút 'Đăng nhập bằng Steam' vào site mà không cần tự đăng ký với Steam. Bạn nhận được: name, avatar and SteamID (no email)

🕒 Cập nhật lần cuối: Giờ Thái Lan (UTC+07:00) · ✅ Mã cũ vẫn chạy, không cần sửa

🤖 Nhờ AI viết mã tích hợp

Sao chép liên kết này cho AI đọc (toàn bộ API dạng Markdown) hoặc bấm nút: lời nhắc được sao chép và AI được mở

https://api.tungkao.com/docs/api/steam_login.md?lang=vi
https://api.tungkao.com/changelog/steam_login.json

Liên kết này trả về các cập nhật của API dưới dạng JSON (không cần key, mọi nguồn). Hãy hiển thị trong trang quản trị như hộp “Thông báo cập nhật” và gắn “Mới” khi last_updated thay đổi

ChatGPT ↗Claude ↗Gemini ↗Grok ↗

Sao chép + mở: Bấm nút AI sẽ tự sao chép lời nhắc — nếu ô chat trống, chỉ cần dán

🔑 Key cần dùng

Tạo key steam_login trong cổng bán hàng (API key) và gửi header này với mọi yêu cầu — key của dịch vụ khác không dùng được ở đây

Authorization: Bearer $TUNGKAO_KEY

🔗 Liên kết nút đăng nhập của bạn

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

🛡️ Mọi bước kết thúc tại tungkao: người dùng đăng nhập với Steam rồi luôn quay về tungkao trước. Chỉ khi đăng nhập thật sự thành công (hoặc hủy trong lúc đăng nhập) mới chuyển tới liên kết của bạn — ai mở liên kết trực tiếp chỉ thấy trang tungkao. Đặt 🌐 tên miền (xác minh) và ↩️ liên kết quay về ở 'Thành viên'.

Bạn nhận được: name, avatar and SteamID (no email)

📋 Các bước

  1. Tạo key cho nhà cung cấp, rồi ở 'Thành viên đăng nhập' đặt tên site và redirect URI (https, khớp chính xác).
  2. Nút đăng nhập đưa người dùng tới /oauth/authorize kèm client_id (ID key), redirect_uri và state (ngẫu nhiên mới, lưu trong session).
  3. Người dùng quay về redirect_uri?code=…&state=… → kiểm tra state → máy chủ gọi POST /v1/login/token trong vòng 2 phút.
  4. Dùng data.user (vd 7F3K9QX2-yourshopcom) làm ID thành viên — cùng một người luôn cùng một ID.

📡 Gọi API + mã mẫu

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

Trường hợpCài đặt key (trang API Keys)Kết quả
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.

Ví dụ đầy đủ (nút + callback + đổi 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);
Nhà cung cấpDịch vụBạn nhận được
Googlegoogle_logintên, email đã xác minh, ảnh
LINEline_logintên, ảnh, email nếu người dùng đồng ý
Facebookfacebook_logintên, ảnh, email
TikToktiktok_logintên hiển thị, ảnh đại diện (không email)
Discorddiscord_logintên, ảnh đại diện, email
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

📚 Ví dụ sử dụng

Ví dụ 1

A “Sign in with Steam” button on your site

Tình huống: A visitor taps Sign in with Steam on your site

Yêu cầu
GET /oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https://yourshop.com/auth/callback&state=xyz

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

Ví dụ 2

Exchange the code for the user (server side)

Tình huống: Your server receives the code on the callback page (exchange within 2 minutes)

Yêu cầu
POST /v1/login/token
{
  "code": "<code from the callback>",
  "redirect_uri": "https://yourshop.com/auth/callback"
}
Phản hồi mẫu
{
  "success": true,
  "data": {
    "user": "7F3K9QX2-yourshopcom",
    "provider": "steam",
    "name": "Somchai",
    "is_new_user": true
  }
}

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

Ví dụ 3

A returning user signs in

Tình huống: The same person signs in with Steam again

Phản hồi mẫu
{
  "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

Ví dụ 4

One site, two Steam keys (website + app)

Tình huống: 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

Ví dụ 5

List members who signed in

Tình huống: You want to browse or search members of this key

Yêu cầu
GET /v1/login/users?q=somchai&limit=50

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

Ví dụ 6

The user cancels during sign-in

Tình huống: The user cancels on the Steam screen

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

💡 Thêm

📜 Lịch sử cập nhật API này

  1. Bổ sung Giờ Thái Lan (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
  2. Bổ sung Giờ Thái Lan (UTC+07:00)
    15 new sign-in providers: Apple, Steam, Twitch, LinkedIn, Kakao, NAVER, Zalo, Spotify, Reddit, GitLab, Roblox, Epic Games, Yahoo, Slack, Amazon. Same /oauth/authorize link and POST /v1/login/token as every existing provider (each one goes on sale when ready; see the services page)
  3. Bổ sung Giờ Thái Lan (UTC+07:00)
    API update announcements by webhook: new api.update event (opt in per key on the key card; off by default)
  4. Bổ sung Giờ Thái Lan (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)
  5. Bổ sung Giờ Thái Lan (UTC+07:00)
    GET /status: trạng thái API theo từng dịch vụ (không cần key)
  6. Bổ sung Giờ Thái Lan (UTC+07:00)
    Công tắc bật/tắt key kèm thời điểm đổi trạng thái + mỗi website 1 key cho mỗi dịch vụ
  7. Cải tiến Giờ Thái Lan (UTC+07:00)
    Khóa vĩnh viễn API v1 (chỉ bổ sung) + header X-Tungkao-Api-Version + báo ngừng trước 12 tháng
  8. Tài liệu Giờ Thái Lan (UTC+07:00)
    Trang tài liệu riêng cho từng API kèm liên kết AI (10 ngôn ngữ)
  9. Bảo mật Giờ Thái Lan (UTC+07:00)
    Xác minh tên miền cho từng API key (1 key = 1 site) — key cũ vẫn hoạt động
  10. Bổ sung Giờ Thái Lan (UTC+07:00)
    Ký yêu cầu HMAC tùy chọn — không bật thì không đổi gì
  11. Bổ sung Giờ Thái Lan (UTC+07:00)
    Thời hạn API key, nhắc hết hạn và gia hạn — chuỗi key không đổi
  12. Bổ sung Giờ Thái Lan (UTC+07:00)
    Key chế độ test (mô phỏng, miễn phí) cho mọi dịch vụ

✅ Mã cũ vẫn chạy, không cần sửa

🛡️ Cam kết ổn định: tích hợp một lần, chạy mãi

🚦 Trạng thái hệ thống (GET /status)

Kiểm tra API có bình thường không bất cứ lúc nào — không cần key

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"
  }
}

🏷️ Yêu cầu ghi nguồn TUNGKAO

Powered by TUNGKAO