VPS.org API

د REST API اسناد

سنیپ شاټونه API

د سرور سنیپ شاټونه د چټک پوائنټ-ان-ټائم بیا رغونې لپاره اداره کړئ. سنیپ شاټونه ستاسو د سرور بشپړ حالت نیسي.

د پای ټکي 4 endpoints
بنسټیزه لاره /api/v1/snapshots
ترلاسه کړئ /api/v1/snapshots/

ټول سنیپ شاټونه لیست کړئ

ستاسو په سرورونو کې د ټولو سنیپ شاټونو لیست ترلاسه کړئ.

د پوښتنې پیرامیټرې

پیرامیټر ډول اړین دی تفصیل
server_id integer نه د سرور ID له مخې سنیپ شاټونه فلټر کړئ

د غوښتنې بېلګه

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

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

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

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

د ځواب بېلګه

{
  "count": 2,
  "results": [
    {
      "id": 801,
      "server": {
        "id": 12345,
        "name": "web-server-01"
      },
      "name": "pre-migration-snapshot",
      "status": "completed",
      "size_mb": 5120,
      "created_at": "2025-01-15T18:30:00Z",
      "description": "Before major migration"
    },
    {
      "id": 798,
      "server": {
        "id": 12345,
        "name": "web-server-01"
      },
      "name": "weekly-snapshot-2025-01-08",
      "status": "completed",
      "size_mb": 4856,
      "created_at": "2025-01-08T12:00:00Z",
      "description": "Weekly snapshot"
    }
  ]
}

د غبرګون حالت کوډونه

200 د سنیپ شاټ لیست په بریالیتوب سره ترلاسه شو
401 غیر مجاز - د تصدیق نښه ناسمه یا ورکه ده
پوسټ /api/v1/snapshots/

سنیپ شاټ جوړ کړئ

Create a snapshot of a server's current state. Snapshots are point-in-time copies of the entire server.

د بدن پیرامیټرو غوښتنه وکړئ

پیرامیټر ډول اړین دی تفصیل
server_id integer هو د سنیپ شاټ لپاره د سرور ID
name string هو د سنیپ شاټ نوم (الفانومریک، هایفنز، انډر سکور)
description string نه د سنیپ شاټ لپاره اختیاري توضیحات

د غوښتنې بېلګه

cURL
Python
JavaScript
curl -X POST "https://admin.vps.org/api/v1/snapshots/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "server_id": 12345,
    "name": "before-update-snapshot",
    "description": "Snapshot before system update"
  }'
import requests

url = "https://admin.vps.org/api/v1/snapshots/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {
    "server_id": 12345,
    "name": "before-update-snapshot",
    "description": "Snapshot before system update"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/snapshots/', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    server_id: 12345,
    name: 'before-update-snapshot',
    description: 'Snapshot before system update'
  })
});

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

د ځواب بېلګه

{
  "id": 802,
  "server": {
    "id": 12345,
    "name": "web-server-01"
  },
  "name": "before-update-snapshot",
  "status": "in_progress",
  "size_mb": null,
  "created_at": "2025-01-16T16:15:00Z",
  "description": "Snapshot before system update",
  "message": "Snapshot is being created. This may take 3-10 minutes depending on server size."
}

د غبرګون حالت کوډونه

201 د سنیپ شاټ جوړول په بریالیتوب سره پیل شول
400 Bad Request - Invalid parameters or snapshot limit reached
401 غیر مجاز - د تصدیق نښه ناسمه یا ورکه ده
404 Not Found - Server does not exist
یادونه: You can have a maximum of 5 snapshots per server. Creating a snapshot while the server is running may result in filesystem inconsistencies. For best results, stop the server before creating a snapshot.
پوسټ /api/v1/snapshots/{snapshot_id}/restore/

له سنیپ شاټ څخه بیرته راګرځول

Restore a server to the state captured in a snapshot. This will overwrite all current data on the server.

د لارې پیرامیټرې

پیرامیټر ډول اړین دی تفصیل
snapshot_id integer هو د سنیپ شاټ ځانګړی ID

د غوښتنې بېلګه

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

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

response = requests.post(url, headers=headers)
print(response.json())
const snapshotId = 801;
const response = await fetch(`https://admin.vps.org/api/v1/snapshots/${snapshotId}/restore/`, {
  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 being restored from snapshot. This may take 5-15 minutes.",
  "snapshot": {
    "id": 801,
    "name": "pre-migration-snapshot",
    "created_at": "2025-01-15T18:30:00Z"
  },
  "server": {
    "id": 12345,
    "name": "web-server-01",
    "status": "restoring"
  }
}

د غبرګون حالت کوډونه

200 بیا رغونه په بریالیتوب سره پیل شوه
400 Bad Request - Server is not in a valid state for restoration
401 غیر مجاز - د تصدیق نښه ناسمه یا ورکه ده
404 ونه موندل شو - سنیپ شاټ شتون نلري
خبرداری: Restoring from a snapshot will overwrite all current data on the server. This action cannot be undone. The server will be automatically stopped before restoration begins.
ړنګول /api/v1/snapshots/{snapshot_id}/

سنیپ شاټ ړنګ کړئ

یو سنیپ شاټ په دایمي ډول ړنګ کړئ. دا عمل بیرته نشي راوستل کیدی.

د لارې پیرامیټرې

پیرامیټر ډول اړین دی تفصیل
snapshot_id integer هو د سنیپ شاټ ځانګړی ID

د غوښتنې بېلګه

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

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

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

د غبرګون حالت کوډونه

204 سنیپ شاټ په بریالیتوب سره ړنګ شو
401 غیر مجاز - د تصدیق نښه ناسمه یا ورکه ده
404 ونه موندل شو - سنیپ شاټ شتون نلري

Snapshots vs Backups

Understanding when to use snapshots versus backups:

سنیپ شاټونه API

  • موخه: Quick point-in-time recovery
  • سرعت: Faster to create and restore (3-15 min)
  • د کارولو قضیه: Before risky operations (updates, config changes)
  • ذخیره کول: Stored on same infrastructure
  • حد: 5 snapshots per server
  • غوره د: Short-term rollback capability

د بیک اپ API

  • موخه: Long-term data protection
  • سرعت: Slower to create and restore (varies)
  • د کارولو قضیه: Regular automated data protection
  • ذخیره کول: Separate backup storage
  • حد: 10 manual + automatic backups
  • غوره د: Disaster recovery and compliance

Best Practices