XYRIS.SPACE API Documentation

TÀI LIỆU HƯỚNG DẪN SỬ DỤNG API

Base URL: https://root.xyris.space

Giới thiệu

CTDO API là một RESTful API hiện đại được thiết kế để cung cấp các dịch vụ dữ liệu mạnh mẽ cho ứng dụng của bạn. API này sử dụng các tiêu chuẩn web hiện đại và được xây dựng với hiệu suất cao.

Tài liệu này sẽ hướng dẫn bạn cách sử dụng các endpoint có sẵn, cách xác thực và các ví dụ thực tế.

I. XÁC THỰC (AUTHENTICATION)

Tất cả các endpoint (ngoại trừ /api/auth/register và /api/auth/login) đều yêu cầu xác thực bằng Token. Gửi Token trong Header của mỗi request:

Authorization Header
Authorization: Bearer <your_token_here>

POST Đăng ký tài khoản

Endpoint: /api/auth/register

Body (JSON):

JSON
{
  "username": "testuser",
  "email": "test@example.com",
  "password": "password123",
  "confirm_password": "password123"
}

Success Response (201):

JSON
{
  "success": true,
  "message": "Đăng ký thành công! Vui lòng đăng nhập."
}

POST Đăng nhập

Endpoint: /api/auth/login

Body (JSON):

JSON
{
  "username": "testuser",
  "password": "password123"
}

Success Response (200):

JSON
{
  "success": true,
  "message": "Đăng nhập thành công!",
  "token": "a1b2c3d4e5f6..."
}

POST Đăng nhập bằng Token (Remember Me)

Endpoint: /api/auth/token-login
Authentication: Required
Body: (empty)

Success Response (200):

JSON
{
  "success": true,
  "message": "Token hợp lệ."
}

II. NGƯỜI DÙNG (USER)

GET Lấy thông tin chi tiết người dùng

Endpoint: /api/user/info
Authentication: Required

Success Response (200):

JSON
{
  "success": true,
  "message": "Lấy thông tin người dùng thành công.",
  "data": {
    "id": 1,
    "username": "testuser",
    "email": "test@example.com",
    "balance": "10000",
    "role": 0,
    "role_text": "Normal Member",
    "status": 1,
    "created_date": "2023-10-27T10:00:00.000Z",
    "key_limit": 500,
    "package_limit": 5,
    "namekey_limit": 5,
    "uuid_limit": 2,
    "stats": {
      "total_created_keys": 50,
      "total_unused_keys": 20,
      "total_locked_keys": 5,
      "total_packages": 2,
      "total_namekeys": 3
    }
  }
}

PUT Đổi mật khẩu

Endpoint: /api/user/change-password
Authentication: Required

Body (JSON):

JSON
{
  "old_password": "current_password123",
  "new_password": "new_strong_password456",
  "confirm_password": "new_strong_password456"
}

Success Response (200):

JSON
{
  "success": true,
  "message": "Đổi mật khẩu thành công!"
}

DELETE Xóa tài khoản

Endpoint: /api/user/delete-account
Authentication: Required

CẢNH BÁO

Hành động này không thể hoàn tác. Toàn bộ dữ liệu của người dùng (packages, keys, namekeys, v.v.) sẽ bị xóa vĩnh viễn.

Body (JSON):

JSON
{
  "password": "current_password123"
}

Success Response (200):

JSON
{
  "success": true,
  "message": "Tài khoản và tất cả dữ liệu liên quan đã được xóa vĩnh viễn."
}

Endpoints

Dưới đây là danh sách các endpoint có sẵn trong XYRIS.SPACE API:

GET /users

Lấy danh sách người dùng

Lấy danh sách tất cả người dùng trong hệ thống

Parameters

Tham số Kiểu Mô tả
page integer Số trang (mặc định: 1)
limit integer Số lượng kết quả mỗi trang (mặc định: 10)

Response

Response Body
{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "Nguyễn Văn A",
      "email": "a@example.com"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 100
  }
}
POST /users

Tạo người dùng mới

Tạo một người dùng mới trong hệ thống

Request Body

Tham số Kiểu Bắt buộc Mô tả
name string Tên người dùng
email string Email người dùng

Request Example

Request Body
{
  "name": "Nguyễn Văn B",
  "email": "b@example.com"
}

Response

Response Body
{
  "success": true,
  "data": {
    "id": 2,
    "name": "Nguyễn Văn B",
    "email": "b@example.com",
    "createdAt": "2023-11-27T10:30:00Z"
  }
}
GET /users/:id

Lấy thông tin người dùng

Lấy thông tin chi tiết của một người dùng cụ thể

Parameters

Tham số Kiểu Mô tả
id integer ID của người dùng

Response

Response Body
{
  "success": true,
  "data": {
    "id": 1,
    "name": "Nguyễn Văn A",
    "email": "a@example.com",
    "createdAt": "2023-11-20T14:30:00Z",
    "updatedAt": "2023-11-25T09:15:00Z"
  }
}

III. GÓI (PACKAGES)

GET Lấy danh sách Packages

Endpoint: /api/packages
Authentication: Required

Success Response (200):

JSON
{
  "success": true,
  "message": "Lấy danh sách package thành công.",
  "data": [
    {
      "id": 1,
      "debname": "My App",
      "debversion": "1.0",
      "debhash": "testuser-a1b2c3...",
      /* ... other fields ... */
    }
  ]
}

POST Tạo Package mới

Endpoint: /api/packages
Authentication: Required

Body (JSON):

JSON
{
  "debname": "New Awesome App",
  "debversion": "1.1",
  "debcontact": "https://t.me/your_contact",
  "newdeblink": "Tiêu đề nhập key",
  "debstatus": true 
}

Success Response (201):

JSON
{
  "success": true,
  "message": "Tạo package thành công.",
  "data": {
    "id": 2,
    "debhash": "testuser-f6e5d4..."
  }
}

PUT Chỉnh sửa Package

Endpoint: /api/packages/{id}
Authentication: Required

Body (JSON):

JSON
{
  "newdeblink": "Tiêu đề đã được cập nhật",
  "debcontact": "https://facebook.com/your_contact"
}

Success Response (200):

JSON
{
  "success": true,
  "message": "Cập nhật package thành công."
}

PUT Bật/Tắt trạng thái bảo trì

Endpoint: /api/packages/{id}/toggle-status
Authentication: Required
Body: (empty)

Success Response (200):

JSON
{
  "success": true,
  "message": "Đã khóa package." 
}

DELETE Xóa Package (và tất cả key bên trong)

Endpoint: /api/packages/{id}
Authentication: Required

CẢNH BÁO

Hành động này sẽ xóa package và tất cả key liên quan. Hành động này không thể hoàn tác.

Success Response (200):

JSON
{
  "success": true,
  "message": "Đã xóa package và tất cả key liên quan."
}

DELETE Xóa tất cả Key của một Package

Endpoint: /api/packages/{id}/keys
Authentication: Required

Success Response (200):

JSON
{
  "success": true,
  "message": "Đã xóa tất cả key của package này."
}

IV. KEY

GET Lấy danh sách Key

Endpoint: /api/keys
Authentication: Required

Success Response (200):

JSON
{
  "success": true,
  "message": "Lấy danh sách key thành công.",
  "data": [
    {
      "id": 101,
      "package_id": 1,
      "package_name": "My App",
      "devicekey": "testuser-7D-ABC...",
      /* ... other fields ... */
    }
  ]
}

POST Tạo Key mới

Endpoint: /api/keys
Authentication: Required

Body (JSON):

JSON
{
  "type": "static", 
  "quantity": 10,
  "package_id": 1,
  "name_key": "testuser",
  "max_uuid": 1,
  "expiry_date": "2025-12-31 23:59:59", 
  "date_count": null 
}

Ghi chú

"type": "static", "dynamic", hoặc "gen".
"expiry_date": Bắt buộc cho type="static".
"date_count": Bắt buộc cho type="dynamic" hoặc "gen" (tính theo số ngày, VD: 7, 0.5, 30).

Success Response (201):

JSON
{
  "success": true,
  "message": "Tạo thành công 10 key.",
  "data": {
    "created_keys": [
      "testuser-365D-...",
      /* ... 9 more keys ... */
    ]
  }
}

DELETE Xóa một Key

Endpoint: /api/keys/{id}
Authentication: Required

Success Response (200):

JSON
{ "success": true, "message": "Đã xóa key thành công." }

POST Reset UUID của Key

Endpoint: /api/keys/{id}/reset-uuid
Authentication: Required

Success Response (200):

JSON
{ "success": true, "message": "Đã reset UUID thành công." }

PUT Khóa/Mở khóa Key

Endpoint: /api/keys/{id}/toggle-status
Authentication: Required

Success Response (200):

JSON
{ "success": true, "message": "Đã khóa key." }

PUT Cập nhật giới hạn UUID

Endpoint: /api/keys/{id}/uuid-limit
Authentication: Required

Body (JSON):

JSON
{ "new_limit": 2 }

Success Response (200):

JSON
{ "success": true, "message": "Đã cập nhật giới hạn UUID." }

POST Gia hạn Key

Endpoint: /api/keys/{id}/extend
Authentication: Required

Body (JSON):

JSON
{ "additional_hours": 24 }

Success Response (200):

JSON
{ "success": true, "message": "Đã gia hạn thời gian thành công." }

POST Hành động hàng loạt

Endpoint: /api/keys/batch-actions
Authentication: Required

Body (JSON):

JSON
/* Xóa key hết hạn */
{ "action": "delete_expired" }

/* Xóa các key đã chọn */
{ "action": "delete_selected", "key_ids": [101, 102, 105] }

/* Xóa tất cả key */
{ "action": "delete_all" }

/* Reset UUID tất cả key */
{ "action": "reset_all_uuid" }

Success Response (200):

JSON
{ "success": true, "message": "..." }

V. NAMEKEY

GET Lấy danh sách NameKey

Endpoint: /api/namekeys
Authentication: Required

Ghi chú

Danh sách trả về sẽ tự động bao gồm username của bạn như một NameKey mặc định.

Success Response (200):

JSON
{
  "success": true,
  "message": "Lấy danh sách namekey thành công.",
  "data": [
    { "id": 0, "key_name": "testuser" },
    { "id": 15, "key_name": "MyPrefix" }
  ]
}

POST Tạo NameKey mới

Endpoint: /api/namekeys
Authentication: Required

Body (JSON):

JSON
{
  "new_namekey": "NewPrefix"
}

Ghi chú

Hành động này chỉ thành công nếu tổng số NameKey bạn đã tạo (`total_namekeys`) nhỏ hơn giới hạn (`namekey_limit`) của tài khoản.
Việc tạo một NameKey mới **KHÔNG** làm giảm `namekey_limit` của bạn. Nó chỉ đơn thuần chiếm một "slot" trong giới hạn đó.

Success Response (201):

JSON
{ "success": true, "message": "Đã thêm Name Key thành công." }

DELETE Xóa NameKey

Endpoint: /api/namekeys/{id}
Authentication: Required

LƯU Ý CỰC KỲ QUAN TRỌNG

Xóa một NameKey là hành động **KHÔNG THỂ HOÀN TÁC**.
Hành động này sẽ **GIẢM VĨNH VIỄN** giới hạn `namekey_limit` của tài khoản bạn đi 1.
Ví dụ: Nếu limit của bạn là 3/5, sau khi xóa 1 NameKey, limit sẽ trở thành 2/4.
Nếu `namekey_limit` của bạn đã bằng 0, việc xóa sẽ không làm giảm thêm nữa (không thể có giá trị âm).

Success Response (200):

JSON
{ "success": true, "message": "Đã xóa name key thành công." }

Ví dụ

Dưới đây là một số ví dụ về cách sử dụng XYRIS.SPACE API trong các ngôn ngữ lập trình khác nhau:

JavaScript (fetch)

JavaScript
fetch('https://api.ctdo.com/users', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  }
})
.then(response => response.json())
.then(data => console.log(data));