VPS.org API

REST API ਦਸਤਾਵੇਜ਼ੀਕਰਨ

ਸਰਵਰ API

ਆਪਣੇ VPS ਸਰਵਰਾਂ ਨੂੰ ਪ੍ਰੋਗਰਾਮੇਟਿਕ ਤੌਰ 'ਤੇ ਪ੍ਰਬੰਧਿਤ ਕਰੋ। ਆਪਣੇ ਵਰਚੁਅਲ ਪ੍ਰਾਈਵੇਟ ਸਰਵਰ ਬਣਾਓ, ਕੌਂਫਿਗਰ ਕਰੋ, ਕੰਟਰੋਲ ਕਰੋ ਅਤੇ ਨਿਗਰਾਨੀ ਕਰੋ।

ਅੰਤਮ ਬਿੰਦੂ 9
ਬੇਸ ਪਾਥ /api/v1/servers
ਪ੍ਰਾਪਤ ਕਰੋ /api/v1/servers/

ਸਾਰੇ ਸਰਵਰਾਂ ਦੀ ਸੂਚੀ ਬਣਾਓ

ਆਪਣੇ ਖਾਤੇ ਵਿੱਚ ਸਾਰੇ ਸਰਵਰਾਂ ਦੀ ਸੂਚੀ ਪ੍ਰਾਪਤ ਕਰੋ।

ਪੁੱਛਗਿੱਛ ਪੈਰਾਮੀਟਰ

ਪੈਰਾਮੀਟਰ ਦੀ ਕਿਸਮ ਲੋੜੀਂਦਾ ਵੇਰਵਾ
status ਸਤਰ ਨਹੀਂ ਸਰਵਰ ਸਥਿਤੀ ਅਨੁਸਾਰ ਫਿਲਟਰ ਕਰੋ: ਕਿਰਿਆਸ਼ੀਲ, ਰੁਕਿਆ ਹੋਇਆ, ਮੁਅੱਤਲ ਕੀਤਾ ਗਿਆ
location ਸਤਰ ਨਹੀਂ ਡਾਟਾਸੈਂਟਰ ਦੇ ਟਿਕਾਣੇ ਅਨੁਸਾਰ ਫਿਲਟਰ ਕਰੋ

ਉਦਾਹਰਨ ਬੇਨਤੀ

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);

ਉਦਾਹਰਨ ਜਵਾਬ

{
  "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"
    }
  ]
}

ਜਵਾਬ ਸਥਿਤੀ ਕੋਡ

200 ਸਰਵਰ ਸੂਚੀ ਸਫਲਤਾਪੂਰਵਕ ਪ੍ਰਾਪਤ ਕੀਤੀ ਗਈ
401 ਅਣਅਧਿਕਾਰਤ - ਅਵੈਧ ਜਾਂ ਗੁੰਮ API ਟੋਕਨ
ਪੋਸਟ /api/v1/servers/

ਨਵਾਂ ਸਰਵਰ ਬਣਾਓ

ਨਿਰਧਾਰਤ ਸੰਰਚਨਾ ਦੇ ਨਾਲ ਇੱਕ ਨਵਾਂ VPS ਸਰਵਰ ਤੈਨਾਤ ਕਰੋ।

ਬਾਡੀ ਪੈਰਾਮੀਟਰ ਦੀ ਬੇਨਤੀ ਕਰੋ

ਪੈਰਾਮੀਟਰ ਦੀ ਕਿਸਮ ਲੋੜੀਂਦਾ ਵੇਰਵਾ
name ਸਤਰ ਹਾਂ ਸਰਵਰ ਨਾਮ (ਅੱਖਰ ਅੰਕੀ, ਹਾਈਫਨ ਦੀ ਇਜਾਜ਼ਤ ਹੈ)
plan_id ਪੂਰਨ ਅੰਕ ਹਾਂ VPS ਪਲਾਨ ਦੀ ID
os_id ਪੂਰਨ ਅੰਕ ਹਾਂ ਓਪਰੇਟਿੰਗ ਸਿਸਟਮ ਦੀ ਆਈਡੀ
location ਸਤਰ ਹਾਂ ਡਾਟਾਸੈਂਟਰ ਸਥਾਨ ਕੋਡ
hostname ਸਤਰ ਨਹੀਂ ਸਰਵਰ ਹੋਸਟਨੇਮ (FQDN)
ssh_key_id ਪੂਰਨ ਅੰਕ ਨਹੀਂ ਇੰਸਟਾਲ ਕਰਨ ਲਈ SSH ਕੁੰਜੀ ID
backups_enabled ਬੂਲੀਅਨ ਨਹੀਂ ਆਟੋਮੈਟਿਕ ਬੈਕਅੱਪ ਯੋਗ ਬਣਾਓ (ਡਿਫੌਲਟ: ਗਲਤ)

ਉਦਾਹਰਨ ਬੇਨਤੀ

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);

ਉਦਾਹਰਨ ਜਵਾਬ

{
  "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."
}

ਜਵਾਬ ਸਥਿਤੀ ਕੋਡ

201 ਸਰਵਰ ਸਫਲਤਾਪੂਰਵਕ ਬਣਾਇਆ ਗਿਆ
400 ਗਲਤ ਬੇਨਤੀ - ਅਵੈਧ ਪੈਰਾਮੀਟਰ
401 ਅਣਅਧਿਕਾਰਤ - ਅਵੈਧ ਜਾਂ ਗੁੰਮ API ਟੋਕਨ
402 ਭੁਗਤਾਨ ਲੋੜੀਂਦਾ ਹੈ - ਕਾਫ਼ੀ ਕ੍ਰੈਡਿਟ ਨਹੀਂ ਹਨ
ਪ੍ਰਾਪਤ ਕਰੋ /api/v1/servers/{server_id}/

ਸਰਵਰ ਵੇਰਵੇ ਪ੍ਰਾਪਤ ਕਰੋ

ਕਿਸੇ ਖਾਸ ਸਰਵਰ ਬਾਰੇ ਵਿਸਤ੍ਰਿਤ ਜਾਣਕਾਰੀ ਪ੍ਰਾਪਤ ਕਰੋ।

ਮਾਰਗ ਪੈਰਾਮੀਟਰ

ਪੈਰਾਮੀਟਰ ਦੀ ਕਿਸਮ ਲੋੜੀਂਦਾ ਵੇਰਵਾ
server_id ਪੂਰਨ ਅੰਕ ਹਾਂ ਵਿਲੱਖਣ ਸਰਵਰ ਆਈਡੀ

ਉਦਾਹਰਨ ਬੇਨਤੀ

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);

ਉਦਾਹਰਨ ਜਵਾਬ

{
  "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"
}

ਜਵਾਬ ਸਥਿਤੀ ਕੋਡ

200 ਸਰਵਰ ਵੇਰਵੇ ਸਫਲਤਾਪੂਰਵਕ ਪ੍ਰਾਪਤ ਕੀਤੇ ਗਏ
401 ਅਣਅਧਿਕਾਰਤ - ਅਵੈਧ ਜਾਂ ਗੁੰਮ API ਟੋਕਨ
404 ਨਹੀਂ ਮਿਲਿਆ - ਸਰਵਰ ਮੌਜੂਦ ਨਹੀਂ ਹੈ।
ਪਾਓ /api/v1/servers/{server_id}/

ਅੱਪਡੇਟ ਸਰਵਰ

ਸਰਵਰ ਸੰਰਚਨਾ ਨੂੰ ਅੱਪਡੇਟ ਕਰੋ। ਸਾਰੇ ਖੇਤਰ ਲੋੜੀਂਦੇ ਹਨ।

ਮਾਰਗ ਪੈਰਾਮੀਟਰ

Parameter Type Required Description
server_id integer Yes ਵਿਲੱਖਣ ਸਰਵਰ ਆਈਡੀ

ਬਾਡੀ ਪੈਰਾਮੀਟਰ ਦੀ ਬੇਨਤੀ ਕਰੋ

ਪੈਰਾਮੀਟਰ ਦੀ ਕਿਸਮ ਲੋੜੀਂਦਾ ਵੇਰਵਾ
name ਸਤਰ ਹਾਂ ਸਰਵਰ ਨਾਮ
hostname ਸਤਰ ਹਾਂ ਸਰਵਰ ਹੋਸਟਨੇਮ (FQDN)
backups_enabled ਬੂਲੀਅਨ ਹਾਂ ਆਟੋਮੈਟਿਕ ਬੈਕਅੱਪ ਨੂੰ ਸਮਰੱਥ/ਅਯੋਗ ਕਰੋ

ਉਦਾਹਰਨ ਬੇਨਤੀ

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())

ਜਵਾਬ ਸਥਿਤੀ ਕੋਡ

200 ਸਰਵਰ ਸਫਲਤਾਪੂਰਵਕ ਅੱਪਡੇਟ ਕੀਤਾ ਗਿਆ
400 ਗਲਤ ਬੇਨਤੀ - ਅਵੈਧ ਪੈਰਾਮੀਟਰ
404 ਨਹੀਂ ਮਿਲਿਆ - ਸਰਵਰ ਮੌਜੂਦ ਨਹੀਂ ਹੈ।
ਪੈਚ /api/v1/servers/{server_id}/

ਸਰਵਰ ਨੂੰ ਅੰਸ਼ਕ ਤੌਰ 'ਤੇ ਅੱਪਡੇਟ ਕਰੋ

ਖਾਸ ਸਰਵਰ ਖੇਤਰਾਂ ਨੂੰ ਅੱਪਡੇਟ ਕਰੋ। ਸਿਰਫ਼ ਦਿੱਤੇ ਗਏ ਖੇਤਰਾਂ ਨੂੰ ਅੱਪਡੇਟ ਕੀਤਾ ਜਾਵੇਗਾ।

ਉਦਾਹਰਨ ਬੇਨਤੀ

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())
ਮਿਟਾਓ /api/v1/servers/{server_id}/

ਸਰਵਰ ਮਿਟਾਓ

ਸਰਵਰ ਨੂੰ ਸਥਾਈ ਤੌਰ 'ਤੇ ਮਿਟਾਓ। ਇਸ ਕਾਰਵਾਈ ਨੂੰ ਅਣਕੀਤਾ ਨਹੀਂ ਕੀਤਾ ਜਾ ਸਕਦਾ।

ਉਦਾਹਰਨ ਬੇਨਤੀ

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)

ਜਵਾਬ ਸਥਿਤੀ ਕੋਡ

204 ਸਰਵਰ ਸਫਲਤਾਪੂਰਵਕ ਮਿਟਾਇਆ ਗਿਆ
404 ਨਹੀਂ ਮਿਲਿਆ - ਸਰਵਰ ਮੌਜੂਦ ਨਹੀਂ ਹੈ।
ਪੋਸਟ /api/v1/servers/{server_id}/start/

ਸਰਵਰ ਸ਼ੁਰੂ ਕਰੋ

ਬੰਦ ਕੀਤੇ ਸਰਵਰ 'ਤੇ ਪਾਵਰ।

ਉਦਾਹਰਨ ਬੇਨਤੀ

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);

ਉਦਾਹਰਨ ਜਵਾਬ

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

ਜਵਾਬ ਸਥਿਤੀ ਕੋਡ

200 ਸਰਵਰ ਸਟਾਰਟ ਕਮਾਂਡ ਸਫਲਤਾਪੂਰਵਕ ਭੇਜੀ ਗਈ।
400 ਮਾੜੀ ਬੇਨਤੀ - ਸਰਵਰ ਪਹਿਲਾਂ ਹੀ ਚੱਲ ਰਿਹਾ ਹੈ।
404 ਨਹੀਂ ਮਿਲਿਆ - ਸਰਵਰ ਮੌਜੂਦ ਨਹੀਂ ਹੈ।
ਪੋਸਟ /api/v1/servers/{server_id}/stop/

ਸਰਵਰ ਰੋਕੋ

ਚੱਲ ਰਹੇ ਸਰਵਰ ਨੂੰ ਬੜੀ ਸ਼ਾਨ ਨਾਲ ਬੰਦ ਕਰ ਦਿੱਤਾ।

ਉਦਾਹਰਨ ਬੇਨਤੀ

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())

ਉਦਾਹਰਨ ਜਵਾਬ

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

ਸਰਵਰ ਰੀਬੂਟ ਕਰੋ

ਚੱਲ ਰਹੇ ਸਰਵਰ ਨੂੰ ਬੜੇ ਧਿਆਨ ਨਾਲ ਮੁੜ ਚਾਲੂ ਕਰੋ।

ਉਦਾਹਰਨ ਬੇਨਤੀ

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())

ਉਦਾਹਰਨ ਜਵਾਬ

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

ਜਵਾਬ ਸਥਿਤੀ ਕੋਡ

200 ਸਰਵਰ ਰੀਬੂਟ ਕਮਾਂਡ ਸਫਲਤਾਪੂਰਵਕ ਭੇਜੀ ਗਈ
400 ਮਾੜੀ ਬੇਨਤੀ - ਸਰਵਰ ਨਹੀਂ ਚੱਲ ਰਿਹਾ ਹੈ।
404 ਨਹੀਂ ਮਿਲਿਆ - ਸਰਵਰ ਮੌਜੂਦ ਨਹੀਂ ਹੈ।