VPS.org API

Sgrìobhainnean REST API

API Cùl-taice

Stiùirich cùl-taicean frithealaiche gu prògramaichte. Liostaich, cruthaich, ath-nuadhaich agus cuir às do leth-bhreacan airson do fhrithealaichean.

Puingean-crìochnachaidh 3 endpoints
Slighe Bunait /api/v1/backups
FAIGH /api/v1/backups/

Liostaich a h-uile cùl-taic

Faigh liosta de na cùl-taicean uile air feadh do fhrithealaichean.

Paramadairean a' Cheist

Paramadair Seòrsa Riatanach Tuairisgeul
server_id integer Chan eil Criathraich cùl-taicean a rèir ID an fhrithealaiche
backup_type string Chan eil Criathraich a rèir seòrsa: manual , automatic

Eisimpleir Iarrtais

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

Eisimpleir Freagairt

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

Còdan Inbhe Freagairt

200 Chaidh an liosta cùl-taice fhaighinn air ais gu soirbheachail
401 Gun ùghdarras - Comharra dearbhaidh neo-dhligheach no a dhìth
POST /api/v1/backups/

Cruthaich Cùl-taic Làimhe

Cruthaich cùl-taic làimhe den fhrithealaiche. Cha bhith cùl-taicean làimhe a’ tighinn gu crìch gu fèin-ghluasadach.

Paramadairean Corp Iarrtais

Paramadair Seòrsa Riatanach Tuairisgeul
server_id integer Tha ID an fhrithealaiche ri lethbhreac-glèidhidh
description string Chan eil Tuairisgeul roghainneil airson an cùl-taic

Eisimpleir Iarrtais

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

Eisimpleir Freagairt

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

Còdan Inbhe Freagairt

201 Chaidh cruthachadh cùl-taice a thòiseachadh gu soirbheachail
400 Droch Iarrtas - Paramadairean neo-dhligheach no iarrtas mì-chruthaichte
401 Gun ùghdarras - Comharra dearbhaidh neo-dhligheach no a dhìth
404 Cha deach a lorg - Chan eil am frithealaiche ann
Nota: Faodaidh tu suas ri 10 cùl-taicean làimhe a bhith agad gach frithealaiche. Thèid cùl-taicean fèin-ghluasadach a chumail a rèir poileasaidh gleidhidh cùl-taicean do phlana (mar as trice 7-30 latha).
SGUAB ÀS /api/v1/backups/{backup_id}/

Sguab às cùl-taic

Sguab às cùl-taic gu buan. Chan urrainnear an gnìomh seo a thoirt air ais.

Paramadairean na Slighe

Paramadair Seòrsa Riatanach Tuairisgeul
backup_id integer Tha ID cùl-taice sònraichte

Eisimpleir Iarrtais

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

Còdan Inbhe Freagairt

204 Cùl-taic air a dhubhadh às gu soirbheachail
401 Gun ùghdarras - Comharra dearbhaidh neo-dhligheach no a dhìth
404 Cha deach a lorg - Chan eil cùl-taic ann
Rabhadh: Tha cuir às do chùl-taic maireannach agus chan urrainnear a dhèanamh a-rithist. Dèan cinnteach nach eil feum agad air a’ chùl-taic seo tuilleadh mus cuir thu às dha.

A’ faighinn air ais bho chùl-taicean

Gus frithealaiche ath-nuadhachadh bho chùl-taic, cleachd crìoch-phuing ath-nuadhachaidh API nan Frithealaichean :

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

Airson fiosrachadh mionaideach mu ath-nuadhachadh frithealaiche, faic an Sgrìobhainnean API frithealaichean.

Cleachdaidhean as Fheàrr airson Cùl-taic