VPS.org API

REST API hujjatlari

Serverlar APIsi

VPS serverlaringizni dasturiy ravishda boshqaring. Virtual xususiy serverlaringizni yarating, sozlang, boshqaring va kuzatib boring.

Tugash nuqtalari 9 endpoints
Asosiy yo'l /api/v1/servers
OLING /api/v1/servers/

Barcha serverlarni ro'yxatlash

Hisobingizdagi barcha serverlar ro'yxatini oling.

So'rov parametrlari

Parametr Turi Majburiy Tavsif
status tor Yo'q Server holati bo'yicha filtrlash: faol, to'xtatilgan, to'xtatib qo'yilgan
location tor Yo'q Ma'lumotlar markazi joylashuvi bo'yicha filtrlash

Namunaviy so'rov

cURL
Python
JavaScript
PHP
curl -X GET "https://admin.vps.org/api/v1/servers/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
import requests

url = "https://admin.vps.org/api/v1/servers/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/servers/', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

const servers = await response.json();
console.log(servers);
$ch = curl_init('https://admin.vps.org/api/v1/servers/');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$servers = json_decode($response, true);
curl_close($ch);

Javob namunasi

{
  "count": 2,
  "results": [
    {
      "id": 12345,
      "name": "web-server-01",
      "hostname": "web01.example.com",
      "status": "active",
      "ip_address": "203.0.113.10",
      "location": "us-west",
      "plan": {
        "id": 1,
        "name": "Standard VPS",
        "vcpus": 2,
        "memory": 4096,
        "storage": 80
      },
      "os": {
        "id": 5,
        "name": "Ubuntu 22.04 LTS"
      },
      "created_at": "2025-01-10T14:30:00Z",
      "updated_at": "2025-01-15T10:20:00Z"
    },
    {
      "id": 12346,
      "name": "db-server-01",
      "hostname": "db01.example.com",
      "status": "active",
      "ip_address": "203.0.113.11",
      "location": "us-east",
      "plan": {
        "id": 2,
        "name": "Performance VPS",
        "vcpus": 4,
        "memory": 8192,
        "storage": 160
      },
      "os": {
        "id": 3,
        "name": "Debian 12"
      },
      "created_at": "2025-01-12T09:15:00Z",
      "updated_at": "2025-01-16T08:45:00Z"
    }
  ]
}

Javob holati kodlari

200 Serverlar ro'yxati muvaffaqiyatli olindi
401 Ruxsatsiz - API tokeni yaroqsiz yoki yo'q
POCHTA /api/v1/servers/

Yangi server yaratish

Belgilangan konfiguratsiyaga ega yangi VPS serverini joylashtiring.

Tana parametrlarini so'rash

Parametr Turi Majburiy Tavsif
name tor Ha Server nomi (harf-raqam, defislarga ruxsat beriladi)
plan_id butun son Ha VPS rejasining identifikatori
os_id butun son Ha Operatsion tizim identifikatori
location tor Ha Ma'lumotlar markazi joylashuv kodi
hostname tor Yo'q Server xost nomi (FQDN)
ssh_key_id butun son Yo'q O'rnatish uchun SSH kalit identifikatori
backups_enabled mantiqiy Yo'q Avtomatik zaxira nusxalarini yoqish (standart: noto'g'ri)

Namunaviy so'rov

cURL
Python
JavaScript
PHP
curl -X POST "https://admin.vps.org/api/v1/servers/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "web-server-02",
    "plan_id": 1,
    "os_id": 5,
    "location": "us-west",
    "hostname": "web02.example.com",
    "backups_enabled": true
  }'
import requests

url = "https://admin.vps.org/api/v1/servers/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {
    "name": "web-server-02",
    "plan_id": 1,
    "os_id": 5,
    "location": "us-west",
    "hostname": "web02.example.com",
    "backups_enabled": True
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/servers/', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'web-server-02',
    plan_id: 1,
    os_id: 5,
    location: 'us-west',
    hostname: 'web02.example.com',
    backups_enabled: true
  })
});

const server = await response.json();
console.log(server);
$data = [
    'name' => 'web-server-02',
    'plan_id' => 1,
    'os_id' => 5,
    'location' => 'us-west',
    'hostname' => 'web02.example.com',
    'backups_enabled' => true
];

$ch = curl_init('https://admin.vps.org/api/v1/servers/');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$server = json_decode($response, true);
curl_close($ch);

Javob namunasi

{
  "id": 12347,
  "name": "web-server-02",
  "hostname": "web02.example.com",
  "status": "provisioning",
  "ip_address": null,
  "location": "us-west",
  "plan": {
    "id": 1,
    "name": "Standard VPS",
    "vcpus": 2,
    "memory": 4096,
    "storage": 80
  },
  "os": {
    "id": 5,
    "name": "Ubuntu 22.04 LTS"
  },
  "backups_enabled": true,
  "created_at": "2025-01-16T15:30:00Z",
  "updated_at": "2025-01-16T15:30:00Z",
  "message": "Server is being provisioned. This may take 2-5 minutes."
}

Javob holati kodlari

201 Server muvaffaqiyatli yaratildi
400 Noto'g'ri so'rov - Noto'g'ri parametrlar
401 Ruxsatsiz - API tokeni yaroqsiz yoki yo'q
402 To'lov talab qilinadi - Kreditlar yetarli emas
OLING /api/v1/servers/{server_id}/

Server tafsilotlarini oling

Muayyan server haqida batafsil ma'lumot oling.

Yo'l parametrlari

Parametr Turi Majburiy Tavsif
server_id butun son Ha Noyob server identifikatori

Namunaviy so'rov

cURL
Python
JavaScript
curl -X GET "https://admin.vps.org/api/v1/servers/12345/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
import requests

server_id = 12345
url = f"https://admin.vps.org/api/v1/servers/{server_id}/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

response = requests.get(url, headers=headers)
print(response.json())
const serverId = 12345;
const response = await fetch(`https://admin.vps.org/api/v1/servers/${serverId}/`, {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

const server = await response.json();
console.log(server);

Javob namunasi

{
  "id": 12345,
  "name": "web-server-01",
  "hostname": "web01.example.com",
  "status": "active",
  "ip_address": "203.0.113.10",
  "ipv6_address": "2001:0db8::1",
  "location": "us-west",
  "plan": {
    "id": 1,
    "name": "Standard VPS",
    "vcpus": 2,
    "memory": 4096,
    "storage": 80,
    "bandwidth": 2048
  },
  "os": {
    "id": 5,
    "name": "Ubuntu 22.04 LTS"
  },
  "backups_enabled": true,
  "resource_usage": {
    "cpu_percent": 23.5,
    "memory_used": 2048,
    "disk_used": 35,
    "bandwidth_used": 450
  },
  "created_at": "2025-01-10T14:30:00Z",
  "updated_at": "2025-01-16T15:45:00Z"
}

Javob holati kodlari

200 Server tafsilotlari muvaffaqiyatli olindi
401 Ruxsatsiz - API tokeni yaroqsiz yoki yo'q
404 Topilmadi - Server mavjud emas
QO'YING /api/v1/servers/{server_id}/

Serverni yangilash

Server konfiguratsiyasini yangilang. Barcha maydonlarni to'ldirish shart.

Yo'l parametrlari

Parameter Type Required Description
server_id integer Yes Noyob server identifikatori

Tana parametrlarini so'rash

Parametr Turi Majburiy Tavsif
name tor Ha Server nomi
hostname tor Ha Server xost nomi (FQDN)
backups_enabled mantiqiy Ha Avtomatik zaxira nusxalarini yoqish/o'chirish

Namunaviy so'rov

cURL
Python
curl -X PUT "https://admin.vps.org/api/v1/servers/12345/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "web-server-updated",
    "hostname": "web-updated.example.com",
    "backups_enabled": true
  }'
import requests

server_id = 12345
url = f"https://admin.vps.org/api/v1/servers/{server_id}/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {
    "name": "web-server-updated",
    "hostname": "web-updated.example.com",
    "backups_enabled": True
}

response = requests.put(url, headers=headers, json=data)
print(response.json())

Javob holati kodlari

200 Server muvaffaqiyatli yangilandi
400 Noto'g'ri so'rov - Noto'g'ri parametrlar
404 Topilmadi - Server mavjud emas
YAMOQ /api/v1/servers/{server_id}/

Serverni qisman yangilash

Serverning muayyan maydonlarini yangilang. Faqat taqdim etilgan maydonlar yangilanadi.

Namunaviy so'rov

cURL
Python
curl -X PATCH "https://admin.vps.org/api/v1/servers/12345/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "new-server-name"
  }'
import requests

server_id = 12345
url = f"https://admin.vps.org/api/v1/servers/{server_id}/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {"name": "new-server-name"}

response = requests.patch(url, headers=headers, json=data)
print(response.json())
O'CHIRISH /api/v1/servers/{server_id}/

Serverni o'chirish

Serverni butunlay o'chirish. Bu amalni bekor qilib bo'lmaydi.

Namunaviy so'rov

cURL
Python
curl -X DELETE "https://admin.vps.org/api/v1/servers/12345/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
import requests

server_id = 12345
url = f"https://admin.vps.org/api/v1/servers/{server_id}/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

response = requests.delete(url, headers=headers)
print(response.status_code)

Javob holati kodlari

204 Server muvaffaqiyatli o'chirildi
404 Topilmadi - Server mavjud emas
POCHTA /api/v1/servers/{server_id}/start/

Serverni ishga tushirish

To'xtatilgan serverni yoqing.

Namunaviy so'rov

cURL
Python
JavaScript
curl -X POST "https://admin.vps.org/api/v1/servers/12345/start/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
import requests

server_id = 12345
url = f"https://admin.vps.org/api/v1/servers/{server_id}/start/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers)
print(response.json())
const serverId = 12345;
const response = await fetch(`https://admin.vps.org/api/v1/servers/${serverId}/start/`, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

const result = await response.json();
console.log(result);

Javob namunasi

{
  "status": "success",
  "message": "Server is starting",
  "server": {
    "id": 12345,
    "name": "web-server-01",
    "status": "starting"
  }
}

Javob holati kodlari

200 Serverni ishga tushirish buyrug'i muvaffaqiyatli yuborildi
400 Noto'g'ri so'rov - Server allaqachon ishlayapti
404 Topilmadi - Server mavjud emas
POCHTA /api/v1/servers/{server_id}/stop/

Serverni to'xtatish

Ishlayotgan serverni ehtiyotkorlik bilan o'chirib qo'ying.

Namunaviy so'rov

cURL
Python
curl -X POST "https://admin.vps.org/api/v1/servers/12345/stop/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
import requests

server_id = 12345
url = f"https://admin.vps.org/api/v1/servers/{server_id}/stop/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers)
print(response.json())

Javob namunasi

{
  "status": "success",
  "message": "Server is stopping",
  "server": {
    "id": 12345,
    "name": "web-server-01",
    "status": "stopping"
  }
}
POCHTA /api/v1/servers/{server_id}/reboot/

Serverni qayta ishga tushirish

Ishlayotgan serverni ehtiyotkorlik bilan qayta ishga tushiring.

Namunaviy so'rov

cURL
Python
curl -X POST "https://admin.vps.org/api/v1/servers/12345/reboot/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"
import requests

server_id = 12345
url = f"https://admin.vps.org/api/v1/servers/{server_id}/reboot/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}

response = requests.post(url, headers=headers)
print(response.json())

Javob namunasi

{
  "status": "success",
  "message": "Server is rebooting",
  "server": {
    "id": 12345,
    "name": "web-server-01",
    "status": "rebooting"
  }
}

Javob holati kodlari

200 Serverni qayta ishga tushirish buyrug'i muvaffaqiyatli yuborildi
400 Noto'g'ri so'rov - Server ishlamayapti
404 Topilmadi - Server mavjud emas