VPS.org API

Dokimantasyon API REST la

API pou Sovgad

Jere backup sèvè yo atravè pwogramasyon. Lis, kreye, restore, epi efase backup pou sèvè ou yo.

Pwen final yo 3 endpoints
Chemen Baz la /api/v1/backups
JWENN /api/v1/backups/

Lis tout sovgad yo

Jwenn yon lis tout backup sou sèvè ou yo.

Paramèt Rechèch

Paramèt Kalite Obligatwa Deskripsyon
server_id integer Non Filtre backups pa ID sèvè
backup_type string Non Filtre pa kalite: manual , automatic

Egzanp Demann

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

url = "https://admin.vps.org/api/v1/backups/"
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/backups/?server_id=12345', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

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

Egzanp Repons

{
  "count": 3,
  "results": [
    {
      "id": 501,
      "server": {
        "id": 12345,
        "name": "web-server-01"
      },
      "backup_type": "automatic",
      "status": "completed",
      "size_mb": 4523,
      "created_at": "2025-01-16T03:00:00Z",
      "expires_at": "2025-02-16T03:00:00Z",
      "description": "Automatic daily backup"
    },
    {
      "id": 499,
      "server": {
        "id": 12345,
        "name": "web-server-01"
      },
      "backup_type": "manual",
      "status": "completed",
      "size_mb": 4456,
      "created_at": "2025-01-14T10:30:00Z",
      "expires_at": null,
      "description": "Pre-update backup"
    },
    {
      "id": 495,
      "server": {
        "id": 12345,
        "name": "web-server-01"
      },
      "backup_type": "automatic",
      "status": "completed",
      "size_mb": 4389,
      "created_at": "2025-01-15T03:00:00Z",
      "expires_at": "2025-02-15T03:00:00Z",
      "description": "Automatic daily backup"
    }
  ]
}

Kòd Estati Repons yo

200 Lis backup la te rekipere avèk siksè
401 Pa otorize - Jeton otantifikasyon ki pa valab oswa ki manke
PÒS /api/v1/backups/

Kreye yon backup manyèl

Kreye yon backup manyèl pou yon sèvè. Backup manyèl yo pa ekspire otomatikman.

Paramèt Kò Demann lan

Paramèt Kalite Obligatwa Deskripsyon
server_id integer Wi ID sèvè pou backup la
description string Non Deskripsyon opsyonèl pou backup la

Egzanp Demann

cURL
Python
JavaScript
PHP
curl -X POST "https://admin.vps.org/api/v1/backups/" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "server_id": 12345,
    "description": "Pre-deployment backup"
  }'
import requests

url = "https://admin.vps.org/api/v1/backups/"
headers = {
    "Authorization": "Bearer YOUR_API_TOKEN",
    "Content-Type": "application/json"
}
data = {
    "server_id": 12345,
    "description": "Pre-deployment backup"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/backups/', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    server_id: 12345,
    description: 'Pre-deployment backup'
  })
});

const backup = await response.json();
console.log(backup);
$data = [
    'server_id' => 12345,
    'description' => 'Pre-deployment backup'
];

$ch = curl_init('https://admin.vps.org/api/v1/backups/');
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);
$backup = json_decode($response, true);
curl_close($ch);

Egzanp Repons

{
  "id": 502,
  "server": {
    "id": 12345,
    "name": "web-server-01"
  },
  "backup_type": "manual",
  "status": "in_progress",
  "size_mb": null,
  "created_at": "2025-01-16T15:45:00Z",
  "expires_at": null,
  "description": "Pre-deployment backup",
  "message": "Backup is being created. This may take several minutes depending on server size."
}

Kòd Estati Repons yo

201 Kreyasyon backup la te kòmanse avèk siksè
400 Move Demann - Paramèt ki pa valab oswa demann ki mal fòme
401 Pa otorize - Jeton otantifikasyon ki pa valab oswa ki manke
404 Pa jwenn - Sèvè a pa egziste
Nòt: Ou ka gen yon maksimòm de 10 backup manyèl pou chak sèvè. Backup otomatik yo konsève dapre règleman konsèvasyon backup plan ou an (jeneralman 7-30 jou).
EFASE /api/v1/backups/{backup_id}/

Efase Sovgad la

Efase yon backup pou tout tan. Ou pa ka anile aksyon sa a.

Paramèt Chemen

Paramèt Kalite Obligatwa Deskripsyon
backup_id integer Wi ID backup inik

Egzanp Demann

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

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

response = requests.delete(url, headers=headers)
print(response.status_code)
const backupId = 501;
const response = await fetch(`https://admin.vps.org/api/v1/backups/${backupId}/`, {
  method: 'DELETE',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

console.log(response.status);

Kòd Estati Repons yo

204 Sovgad la efase avèk siksè
401 Pa otorize - Jeton otantifikasyon ki pa valab oswa ki manke
404 Pa jwenn - Sovgad la pa egziste
Avètisman: Efase yon backup se yon bagay pèmanan e ou pa ka anile li. Asire w ou pa bezwen backup sa a ankò anvan ou efase li.

Retabli apati sovgad

Pou restore yon sèvè apati yon backup, sèvi ak pwen final restore API Servers la:

POST /api/v1/servers/{server_id}/restore/
{
  "backup_id": 501
}

Pou plis enfòmasyon detaye sou restorasyon sèvè a, gade Dokimantasyon API sèvè yo.

Pi bon pratik pou backup