TUNGKAO ເອກະສານ API
ກົດປຸ່ມແລ້ວເລືອກ “Save as PDF”

TUNGKAO API

ເຂົ້າສູ່ລະບົບດ້ວຍ Spotify

API v1 · ອັບເດດລ່າສຸດ: ເວລາປະເທດໄທ (UTC+07:00)

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

ຕ້ອງສະແດງ “Powered by TUNGKAO” ເປັນລິ້ງໄປ https://tungkao.com ໃນໜ້າທີ່ໃຊ້ບໍລິການ

API · spotify_login

ເຂົ້າສູ່ລະບົບດ້ວຍ Spotify

ໃສ່ປຸ່ມ 'ເຂົ້າສູ່ລະບົບດ້ວຍ Spotify' ໃນເວັບທ່ານໄດ້ທັນທີ ບໍ່ຕ້ອງສະໝັກກັບ Spotify ເອງ ໄດ້ name, email, photo

🕒 ອັບເດດລ່າສຸດ: ເວລາປະເທດໄທ (UTC+07:00) · ✅ ໂຄດເດີມໃຊ້ໄດ້ ບໍ່ຕ້ອງແກ້

🤖 ໃຫ້ AI ຂຽນໂຄດເຊື່ອມຕໍ່ໃຫ້

ສຳເນົາລິ້ງນີ້ໃຫ້ AI ອ່ານ ຫຼື ກົດປຸ່ມ ລະບົບຈະສຳເນົາຄຳສັ່ງ ແລະ ເປີດ AI ໃຫ້

https://api.tungkao.com/docs/api/spotify_login.md?lang=lo
https://api.tungkao.com/changelog/spotify_login.json

ລິ້ງນີ້ສົ່ງລາຍການອັບເດດຂອງ API ນີ້ເປັນ JSON (ບໍ່ຕ້ອງໃຊ້ key ເປີດໄດ້ທຸກໂດເມນ) ໃຫ້ໜ້າຫຼັງບ້ານສະແດງເປັນກ່ອງ “ປະກາດອັບເດດ” ແລະ ຂຶ້ນ “ໃໝ່” ເມື່ອ last_updated ປ່ຽນ

ChatGPT ↗Claude ↗Gemini ↗Grok ↗

ສຳເນົາ + ເປີດໃນ: ກົດປຸ່ມ AI ລະບົບຈະສຳເນົາຄຳສັ່ງໃຫ້ ຖ້າຊ່ອງແຊັດວ່າງ ໃຫ້ວາງໄດ້ເລີຍ

🔑 key ທີ່ໃຊ້

ສ້າງ key ບໍລິການ spotify_login ທີ່ໜ້າຮ້ານ (ເມນູ API key) ແລ້ວສົ່ງທຸກຄຳຂໍດ້ວຍ header ດ້ານລຸ່ມ — key ບໍລິການອື່ນໃຊ້ກັບ API ນີ້ບໍ່ໄດ້

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: ຜູ້ໃຊ້ເຂົ້າສູ່ລະບົບກັບ Spotify ແລ້ວກັບມາທີ່ tungkao ກ່ອນສະເໝີ ພວກເຮົາພາໄປລິ້ງຂອງທ່ານສະເພາະເມື່ອເຂົ້າສູ່ລະບົບສຳເລັດແທ້ (ຫຼື ກົດຍົກເລີກລະຫວ່າງເຂົ້າສູ່ລະບົບ) — ຄົນເປີດລິ້ງໂດຍກົງຈະເຫັນແຕ່ໜ້າ tungkao ຕັ້ງ 🌐 ໂດເມນ (ຢືນຢັນ) ແລະ ↩️ ລິ້ງກັບ ທີ່ໜ້າ 'ສະມາຊິກ'

ໄດ້ຂໍ້ມູນ: name, email, photo

📋 ຂັ້ນຕອນ

  1. ສ້າງ key ຂອງຄ່າຍທີ່ຕ້ອງການ ແລ້ວໄປໜ້າ 'ສະມາຊິກເຂົ້າສູ່ລະບົບ' ຕັ້ງຊື່ເວັບ ແລະ ລິ້ງກັບ (https ກົງທຸກຕົວອັກສອນ)
  2. ປຸ່ມເຂົ້າສູ່ລະບົບພາຜູ້ໃຊ້ໄປ /oauth/authorize ພ້ອມ client_id (id ຂອງ key), redirect_uri ແລະ state (ຄ່າສຸ່ມໃໝ່ທຸກຄັ້ງ ເກັບໃນ session)
  3. ຜູ້ໃຊ້ກັບມາ redirect_uri?code=…&state=… → ກວດ state → ເຊີບເວີເອີ້ນ POST /v1/login/token ພາຍໃນ 2 ນາທີ
  4. ໃຊ້ data.user (ເຊັ່ນ 7F3K9QX2-yourshopcom) ເປັນລະຫັດສະມາຊິກ ຄົນເດີມໄດ້ລະຫັດເດີມສະເໝີ

📡 ການເອີ້ນ 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 Spotify” button on your site

ສະຖານະການ: A visitor taps Sign in with Spotify on your site

ສົ່ງຄຳຂໍ
GET /oauth/authorize?client_id=<CLIENT_ID>&redirect_uri=https://yourshop.com/auth/callback&state=xyz

➡️ The user signs in with Spotify 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": "spotify",
    "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 Spotify 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 Spotify 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 Spotify 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)
    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)
  7. ເພີ່ມ ເວລາປະເທດໄທ (UTC+07:00)
    API update announcements by webhook: new api.update event (opt in per key on the key card; off by default)
  8. ເພີ່ມ ເວລາປະເທດໄທ (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)
  9. ເພີ່ມ ເວລາປະເທດໄທ (UTC+07:00)
    GET /status: ສະຖານະ API ແຍກທຸກບໍລິການ (ບໍ່ຕ້ອງໃຊ້ key)
  10. ເພີ່ມ ເວລາປະເທດໄທ (UTC+07:00)
    ສະວິດເປີດ/ປິດ key ພ້ອມເວລາປ່ຽນສະຖານະ + 1 ເວັບ 1 key ຕໍ່ບໍລິການ
  11. ປັບປຸງ ເວລາປະເທດໄທ (UTC+07:00)
    ລັອກ API v1 ຖາວອນ (ເພີ່ມໄດ້ຢ່າງດຽວ) + header X-Tungkao-Api-Version + ແຈ້ງເລີກໃຊ້ລ່ວງໜ້າ 12 ເດືອນ
  12. ເອກະສານ ເວລາປະເທດໄທ (UTC+07:00)
    ໜ້າເອກະສານແຍກທຸກ API ພ້ອມລິ້ງໃຫ້ AI ຄົບ 10 ພາສາ
  13. ຄວາມປອດໄພ ເວລາປະເທດໄທ (UTC+07:00)
    ຢືນຢັນໂດເມນຕໍ່ API key (1 key = 1 ເວັບ) — key ເດີມໃຊ້ໄດ້ຄືເກົ່າ
  14. ເພີ່ມ ເວລາປະເທດໄທ (UTC+07:00)
    ເຊັນຄຳຂໍ (HMAC) ເປັນທາງເລືອກ — ບໍ່ເປີດກໍໃຊ້ໄດ້ຄືເກົ່າ
  15. ເພີ່ມ ເວລາປະເທດໄທ (UTC+07:00)
    ກຳນົດອາຍຸ API key + ແຈ້ງເຕືອນ + ຕໍ່ອາຍຸ key ເດີມໃຊ້ຕໍ່ໄດ້
  16. ເພີ່ມ ເວລາປະເທດໄທ (UTC+07:00)
    key ໂໝດ test (ຈຳລອງ ຟຣີ) ທຸກບໍລິການ

✅ ໂຄດເດີມໃຊ້ໄດ້ ບໍ່ຕ້ອງແກ້

🛡️ ສັນຍາຄວາມໝັ້ນຄົງ: ຂຽນເທື່ອດຽວ ໃຊ້ໄດ້ຕະຫຼອດ

🚦 ສະຖານະລະບົບ (GET /status)

ກວດໄດ້ຕະຫຼອດວ່າ API ປົກກະຕິບໍ່ ບໍ່ຕ້ອງໃຊ້ 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"
  }
}

🏷️ ເງື່ອນໄຂການໃສ່ເຄຣດິດ TUNGKAO

Powered by TUNGKAO