อ้างอิงชนิดข้อมูลและข้อผิดพลาด

TypeScript ของทุก request / response ขีดจำกัดของข้อมูล และตารางข้อผิดพลาดทั้งหมด

เกี่ยวกับหน้านี้

รวมชนิดข้อมูล (TypeScript) ของทุก request และ response และตารางข้อผิดพลาดทั้งหมดไว้ที่เดียว คัดลอกไปใช้เป็น type ในโปรเจกต์ของคุณได้เลย รายละเอียดการทำงานของแต่ละ endpoint อยู่ที่ Sign in with Minecraft และ Instance API: ผู้เล่น

รูปแบบคำตอบ

ts
// สำเร็จ (HTTP 2xx)
interface ApiResponse<T> {
  statusCode: number; // เท่ากับ HTTP status เช่น 200
  data: T;
}

// ข้อผิดพลาดทั่วไป (HTTP 4xx / 5xx)
interface ApiError {
  statusCode: number;
  message: string;    // ข้อความภาษาอังกฤษที่ระบุสาเหตุ
  error?: string;     // ชื่อมาตรฐานของ HTTP status เช่น "Unauthorized" "Not Found"
}

// ข้อผิดพลาดการตรวจข้อมูลที่ส่งมา (HTTP 400)
interface ValidationError {
  statusCode: 400;
  message: "Validation failed";
  errors: {
    code: string;                 // เช่น "invalid_type" "too_small" "too_big"
    path: (string | number)[];    // ตำแหน่งของฟิลด์ที่ผิด เช่น ["players", 0, "uuid"]
    message: string;              // คำอธิบายของข้อผิดพลาดนั้น
    expected?: string;            // ชนิดที่คาดไว้ (บางกรณี)
  }[];
}
json
{
  "statusCode": 400,
  "message": "Validation failed",
  "errors": [
    { "expected": "string", "code": "invalid_type", "path": ["players", 0, "uuid"], "message": "Invalid input: expected string, received undefined" }
  ]
}

ชนิดข้อมูลทั้งหมด

ทั่วไป

ts
/** UUID ของ Minecraft: 32 หลักฐานสิบหก ตัวพิมพ์เล็ก ไม่มีขีด (ขาออกเป็นรูปนี้เสมอ ขาเข้ารับมีขีดและตัวพิมพ์ใหญ่ได้) */
type MinecraftUuid = string;

/** เวลา ISO 8601 UTC เช่น "2026-10-06T08:30:00.000Z" */
type IsoDateTime = string;

/** ตัวระบุ Instance ที่ใช้ใน path (ฟิลด์ name ไม่ใช่ title) */
type InstanceName = string;

type ApplicationScope = "PLAYERS_READ" | "PLAYERS_WRITE"; // สิทธิ์ต่อ Instance
type AuthScope = "identify";                              // scope ของ Sign in with Minecraft
type PlayerStatus = "ACTIVE" | "PENDING" | "NOT_FOUND";

Auth

ts
// ---- GET {Dashboard}/authorize (query string ของหน้าเว็บ)
interface AuthorizeQuery {
  client_id: string;
  redirect_uri?: string; // จำเป็นเมื่อ callbackType = REDIRECT ต้องตรงกับที่ลงทะเบียน
  scope?: string;        // ค่าเริ่มต้น "identify" คั่นด้วย ช่องว่าง , หรือ +
  state: string;         // 8..200 ตัวอักษร
}

// ---- ผลของ Redirect: query ที่เติมต่อท้าย redirect_uri
type OpenTabResult =
  | { code: string; state: string }                  // ผู้เล่นยืนยัน
  | { error: "access_denied"; state: string };       // ผู้เล่นปฏิเสธหรือยกเลิก

// ---- POST /api/v1/auth/token
interface TokenRequest {
  code: string; // 1..200 ตัวอักษร
}
type TokenResponse = ApiResponse<{
  state: string;
  scopes: AuthScope[];
  player: { uuid: MinecraftUuid; name: string };
}>;

// ---- Webhook (server เราส่งไปหาแอป)
interface AuthCompletedWebhook {
  event: "auth.completed";
  state: string;
  scopes: AuthScope[];
  player: { uuid: MinecraftUuid; name: string };
}
// headers: X-DMS-Timestamp (Unix วินาที เป็นสตริง), X-DMS-Signature ("sha256=" + hex)

Instance API

ts
// ---- GET /api/v1/instances
interface InstanceGrant {
  name: InstanceName;
  title: string;
  scopes: ApplicationScope[];
}
type ListInstancesResponse = ApiResponse<InstanceGrant[]>;

// ---- GET /api/v1/instances/{name}/players
interface InstancePlayer {
  uuid: MinecraftUuid | null;
  name: string | null;
  status: PlayerStatus;
  joinedAt: IsoDateTime;
}
type ListPlayersResponse = ApiResponse<InstancePlayer[]>;

// ---- PUT /api/v1/instances/{name}/players
interface PlayerInput {
  uuid: string;       // 1..64 ตัวอักษร ต้องอ่านเป็น UUID ได้
  username?: string;  // 0..32 ตัวอักษร คำใบ้แสดงผลเท่านั้น
}
interface PutPlayersRequest {
  players: PlayerInput[]; // 1..100
}
type PutPlayersResponse = ApiResponse<{
  added: number;
  pending: number;
  duplicates: number;
  invalid: string[];
}>;

// ---- DELETE /api/v1/instances/{name}/players  และ  /players/{uuid}
interface DeletePlayersRequest {
  players: { uuid: string }[]; // 1..100 (เฉพาะแบบมี body)
}
type DeletePlayersResponse = ApiResponse<{
  removed: number;
  notOnInstance: MinecraftUuid[];
  invalid: string[];
}>;

ขีดจำกัดของข้อมูลที่ส่ง

ฟิลด์ข้อกำหนด
players[]1-100 รายการต่อคำขอ (PUT และ DELETE)
players[].uuidstring 1-64 ตัวอักษร (ต้องเป็น UUID ที่อ่านได้ ไม่งั้นเข้า invalid)
players[].usernamestring 0-32 ตัวอักษร (ใช้เป็นคำใบ้เมื่อเป็นชื่อ Minecraft ที่ถูกต้อง 1-16 ตัว A-Z a-z 0-9 _)
codestring 1-200 ตัวอักษร
statestring 8-200 ตัวอักษร
redirect_uristring ไม่เกิน 500 ตัวอักษร ตรงกับที่ลงทะเบียน
client_id / name ใน pathตรงตัวพิมพ์เล็กใหญ่

ตารางข้อผิดพลาด

ค่า message ต่อไปนี้คือข้อความจริงที่ API ส่งกลับ (ข้อความภาษาอังกฤษ ใช้เทียบในโค้ดได้ แต่ควรอาศัย HTTP status เป็นหลัก)

ทุก endpoint ใต้ /api/v1

สถานะmessageสาเหตุ
401Use "Authorization: Basic base64(client_id:client_secret)"ไม่มี header Authorization หรือไม่ใช่ Basic
401Invalid client credentialsclient_id ไม่มีอยู่ หรือ secret ผิด (หรือเป็น secret ที่ถูกเปลี่ยนไปแล้ว)
400Validation failedbody ชนิดผิด ขาดฟิลด์ที่จำเป็น หรือเกินขีดจำกัด (มี errors)

Instance API

สถานะmessageสาเหตุ
404Instance not foundไม่มี Instance ชื่อนี้ หรือแอปไม่ได้รับ Instance นี้ (ตอบเหมือนกัน)
403This application has no PLAYERS_READ access to that instanceเรียก GET โดยไม่มีสิทธิ์ players:read
403This application has no PLAYERS_WRITE access to that instanceเรียก PUT หรือ DELETE โดยไม่มีสิทธิ์ players:write

POST /api/v1/auth/token

สถานะmessageสาเหตุ
400Invalid or expired codecode ไม่มี หมดอายุ (เกิน 5 นาที) ใช้ไปแล้ว หรือออกให้แอปอื่น

หน้า /authorize และ Launcher (ผู้เล่นเห็น)

สถานะmessageสาเหตุ
404Unknown applicationไม่มีแอปที่ client_id นี้
400redirect_uri is not registered for this applicationRedirect แต่ไม่ส่ง redirect_uri หรือไม่ตรงที่ลงทะเบียน
400Unknown scope: <ชื่อ>ขอ scope ที่ไม่มีในระบบ
400No scope requestedส่ง scope มาแต่ไม่มีค่าที่ใช้ได้เลย
403This application may not ask for: <ชื่อ>แอปไม่ได้เปิด scope นั้น
400This application has no webhook setโหมด Webhook แต่ยังไม่มี webhookUrl
404This sign-in request has expired or was already usedคำขอหมดอายุ (10 นาที) หรือถูกตอบไปแล้ว
400That code does not match the one on the website (n tries left)ผู้เล่นกรอกรหัสใน Launcher ผิด
403Too many wrong codes. Start again from the website.กรอกรหัสผิดครบ 5 ครั้ง คำขอถูกยกเลิก
การจัดการข้อผิดพลาดที่แนะนำ
  • ตัดสินจาก HTTP status ก่อน แล้วค่อยอ่าน message เพื่อแสดงหรือบันทึก log
  • 401 หลังทำงานได้ปกติมาก่อน แปลว่า secret ถูกเปลี่ยน ให้ตรวจ secret ล่าสุดในหน้าแอป
  • 5xx และข้อผิดพลาดเครือข่ายลองใหม่ได้ (PUT และ DELETE ปลอดภัยที่จะส่งซ้ำ) ส่วน 4xx ลองซ้ำก็ได้ผลเดิม ต้องแก้ที่คำขอหรือการตั้งค่า

เอกสารต่างๆ

Term of servicePrivacy Policy

Dimension Studio

ไดแมนชั่น สตูดิโอ

ดิสคอร์ด :

Dimension Studio

เว็บไซต์ :

Dimension Studio

ยูทูป :

Dimension Studio

Copyright © 2024-2026 บริษัท เน็กชันนารี จำกัด (NEXIONARY Company Limited). All rights reserved.

ทะเบียนเลขที่ 50105568159679

Dimension Launcher ไม่มีส่วนเกี่ยวข้องกับ Mojang AB หรือ Microsoft Corporation