VPS.org API

Antontan-taratasy momba ny REST API

API Sary Misongadina

Tantano ny pikantsary amin'ny mpizara mba hahafahana mamerina amin'ny laoniny haingana. Ny pikantsary dia mirakitra ny toe-javatra feno amin'ny mpizara anao.

Teboka farany 4 endpoints
Lalana fototra /api/v1/snapshots
ALAO /api/v1/snapshots/

Tanisao ny sary rehetra

Makà lisitr'ireo snapshot rehetra manerana ny mpizara anao.

Paramètres de requête

fikirana Karazana ilaina Description
server_id integer tsy misy Sivana ireo sary miafina araka ny ID mpizara

Ohatra amin'ny fangatahana

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

Ohatra amin'ny Valiny

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

Kaody momba ny satan'ny valiny

200 Naverina soa aman-tsara ny lisitry ny sary miafina
401 Tsy nahazoana alalana - Tsy manan-kery na tsy ampy ny mari-pamantarana fanamarinana
POST /api/v1/snapshots/

Mamorona topimaso

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

Fangatahana masontsivana momba ny vatana

fikirana Karazana ilaina Description
server_id integer ENY ID an'ny mpizara mankany amin'ny snapshot
name string ENY Anaran'ny sary (alfanoratana, tsipika ambany, tsipika midina)
description string tsy misy Famaritana azo isafidianana ho an'ny sary nalaina

Ohatra amin'ny fangatahana

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

Ohatra amin'ny Valiny

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

Kaody momba ny satan'ny valiny

201 Nanomboka soa aman-tsara ny famoronana sary fohy
400 Bad Request - Invalid parameters or snapshot limit reached
401 Tsy nahazoana alalana - Tsy manan-kery na tsy ampy ny mari-pamantarana fanamarinana
404 Not Found - Server does not exist
Fanamarihana: 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.
POST /api/v1/snapshots/{snapshot_id}/restore/

Avereno amin'ny Snapshot

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

Masontsivana momba ny lalana

fikirana Karazana ilaina Description
snapshot_id integer ENY ID snapshot tokana

Ohatra amin'ny fangatahana

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

Ohatra amin'ny Valiny

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

Kaody momba ny satan'ny valiny

200 Natomboka soa aman-tsara ny famerenana amin'ny laoniny
400 Bad Request - Server is not in a valid state for restoration
401 Tsy nahazoana alalana - Tsy manan-kery na tsy ampy ny mari-pamantarana fanamarinana
404 Tsy hita - Tsy misy ny sary nalaina
Fampitandremana: 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.
Fafao /api/v1/snapshots/{snapshot_id}/

Fafao ny topimaso

Fafao tanteraka ny sary nalaina. Tsy azo foanana ity hetsika ity.

Masontsivana momba ny lalana

fikirana Karazana ilaina Description
snapshot_id integer ENY ID snapshot tokana

Ohatra amin'ny fangatahana

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)

Kaody momba ny satan'ny valiny

204 Voafafa soa aman-tsara ny sary
401 Tsy nahazoana alalana - Tsy manan-kery na tsy ampy ny mari-pamantarana fanamarinana
404 Tsy hita - Tsy misy ny sary nalaina

Snapshots vs Backups

Understanding when to use snapshots versus backups:

API Sary Misongadina

  • Tanjona: Quick point-in-time recovery
  • Hafainganam-pandeha: Faster to create and restore (3-15 min)
  • Fomba fampiasana: Before risky operations (updates, config changes)
  • Fitehirizana: Stored on same infrastructure
  • Fetra: 5 snapshots per server
  • Tsara indrindra ho an'ny: Short-term rollback capability

API backups

  • Tanjona: Long-term data protection
  • Hafainganam-pandeha: Slower to create and restore (varies)
  • Fomba fampiasana: Regular automated data protection
  • Fitehirizana: Separate backup storage
  • Fetra: 10 manual + automatic backups
  • Tsara indrindra ho an'ny: Disaster recovery and compliance

Best Practices