API Key (Token Của Bạn)

Bạn cần đăng nhập để xem API Key.

Tài Liệu Sử Dụng API Hosting

Base URL: https://kvm.dynixvn.net

Xác thực: - Gửi token trong header X-API-Token: your_token HOẶC trong body/query token. - Token là cột token trong tài khoản của bạn.

Response chung: Luôn là JSON


1. Lấy Danh Sách Gói Hosting (Bắt buộc trước khi mua)

Endpoint: /api/getpackage

Method: GET hoặc POST

Token: Tùy chọn

  • Có token: Hiển thị giá sau chiết khấu cá nhân (ck_hosting)
  • Không token: Hiển thị giá gốc (phù hợp guest xem trước)

Ví dụ request (có token):

curl "https://kvm.dynixvn.net/api/getpackage" \
  -H "X-API-Token: your_token"

Ví dụ request (không token):

curl "https://kvm.dynixvn.net/api/getpackage"

Response mẫu (thành công với token):

{
  "status": "success",
  "message": "Lấy danh sách gói hosting thành công",
  "applied_discount": "20%",
  "total_packages": 3,
  "data": [
    {
      "id": 1,
      "name": "HOSTING CHEAP 1",
      "package_name": "cheap1",
      "price_original": 100000,
      "price_discounted": 80000,
      "discount_percent": 20,
      "disk_quota": "10000",
      "bandwidth_limit": "unlimited",
      "max_subdomains": "unlimited",
      "max_parked_domains": "unlimited",
      "max_addon_domains": "unlimited",
      "description": "Mô tả gói chi tiết",
      "language": "vi",
      "cpanel_module": "jupiter"
    }
  ]
}

Response mẫu (không token):

{
  "status": "success",
  "message": "Lấy danh sách gói hosting thành công",
  "applied_discount": "Không (guest)",
  "total_packages": 3,
  "data": [
    {
      "id": 1,
      "name": "HOSTING CHEAP 1",
      "price_original": 100000,
      "price_discounted": 100000,
      "discount_percent": 0
      // ... các trường khác
    }
  ]
}

2. Mua Hosting Mới

Endpoint: /api/buyhosting

Method: GET hoặc POST

Token: Bắt buộc

Parameters:
ParameterTypeRequiredDescription
idintegerYesID gói hosting (lấy từ API lấy gói)
monthsintegerYesSố tháng (1-12,24,36)
domainstringYesTên miền (không http/https/www)
couponstringNoMã giảm giá

Request mẫu:

curl -X POST "https://kvm.dynixvn.net/api/buyhosting" \
  -H "Content-Type: application/json" \
  -H "X-API-Token: your_token" \
  -d '{
    "id": 1,
    "months": 3,
    "domain": "example.com",
    "coupon": "WELCOME10"
  }'

Response thành công:

{
  "status": "success",
  "message": "Hosting purchased successfully",
  "data": {
    "transaction_id": "A1B2C3D4",
    "domain": "example.com",
    "username": "texample",
    "password": "R@nd0mP@ss123",
    "package": "HOSTING CHEAP 1",
    "months": 3,
    "price": 240000,
    "discount_applied": "20%",
    "start_date": "2024-01-01 10:30:00",
    "end_date": "2024-04-01 10:30:00",
    "server_ip": "192.168.1.100",
    "coupon_used": true
  }
}

3. Quản Lý Hosting

Endpoint: /api/actionhosting

Method: GET hoặc POST

Token: Bắt buộc

Actions hỗ trợ:
ActionMethodParametersDescription
get_infoGET/POSThosting_idLấy thông tin hosting
change_passwordPOSThosting_idĐổi mật khẩu hosting
renewPOSThosting_id, monthsGia hạn hosting
deletePOSThosting_idXóa hosting

Ví dụ lấy thông tin hosting:

curl "https://kvm.dynixvn.net/api/actionhosting?action=get_info&hosting_id=123&token=your_token"

Ví dụ gia hạn hosting:

curl -X POST "https://kvm.dynixvn.net/api/actionhosting" \
  -H "Content-Type: application/json" \
  -H "X-API-Token: your_token" \
  -d '{
    "action": "renew",
    "hosting_id": 123,
    "months": 6
  }'

Response thành công (gia hạn):

{
  "status": "success",
  "message": "Hosting renewed successfully",
  "data": {
    "new_end_date": "2024-07-01 10:30:00",
    "months_added": 6,
    "amount_paid": 480000,
    "discount_applied": "20%",
    "transaction_id": "RENEW1234"
  }
}

4. Kiểm Tra Domain (Tự Động)

API /api/buyhosting đã tự động kiểm tra domain trước khi tạo hosting. Nếu domain đã tồn tại trên hệ thống sẽ báo lỗi.

Lỗi domain tồn tại:

{
  "status": "error",
  "message": "Domain already exists on the system"
}

Curl Ví Dụ Đầy Đủ

1. Lấy danh sách gói (có token):
curl "https://kvm.dynixvn.net/api/getpackage" \
  -H "X-API-Token: your_token"
2. Mua hosting:
curl -X POST "https://kvm.dynixvn.net/api/buyhosting" \
  -H "Content-Type: application/json" \
  -H "X-API-Token: your_token" \
  -d '{
    "id": 1,
    "months": 12,
    "domain": "mywebsite.com"
  }'
3. Gia hạn hosting:
curl -X POST "https://kvm.dynixvn.net/api/actionhosting" \
  -H "Content-Type: application/json" \
  -H "X-API-Token: your_token" \
  -d '{
    "action": "renew",
    "hosting_id": 123,
    "months": 6
  }'

Thông Tin Quan Trọng

Lưu ý:
  • Chiết khấu (ck_hosting) được áp dụng tự động khi có token hợp lệ
  • Mỗi token chỉ thuộc về 1 tài khoản - không chia sẻ token
  • Mọi giao dịch đều được log và thông báo cho admin
  • Kiểm tra số dư trước khi thực hiện giao dịch
  • Số tháng hợp lệ: 1-12, 24, 36
  • Tên miền không được chứa http/https/www
Mẹo sử dụng:
  1. Luôn lấy danh sách gói mới nhất trước khi mua (giá có thể thay đổi)
  2. Sử dụng id từ response của /api/getpackage để mua hosting
  3. Kiểm tra domain có sẵn trước khi mua (API tự động kiểm tra)
  4. Lưu trữ hosting_id từ response mua hàng để quản lý sau này
  5. Lưu trữ transaction_id để tra cứu giao dịch

Chi Tiết Response Trường Quan Trọng

TrườngÝ nghĩaVí dụ
price_originalGiá gốc của gói (không chiết khấu)100000
price_discountedGiá sau chiết khấu (nếu có token)80000
discount_percent% chiết khấu đang áp dụng20
disk_quotaDung lượng disk (MB hoặc "unlimited")"10000"
bandwidth_limitGiới hạn bandwidth"unlimited"
transaction_idMã giao dịch duy nhất"A1B2C3D4"
usernameUsername để đăng nhập hosting"texample"
server_ipIP server chứa hosting"192.168.1.100"