VPS.org API

Ìwé Ìdásílẹ̀ API REST

API Àfikún

Ṣàkóso àwọn àfikún olupin ní ìlànà ètò. Ṣe àkọsílẹ̀, ṣẹ̀dá, mú wọn padà bọ̀ sípò, kí o sì pa àwọn àfikún olupin rẹ rẹ́.

Àwọn ìparí 3 endpoints
Ipa-ọna Ipilẹ /api/v1/backups
GBÀ /api/v1/backups/

Ṣe àkójọ gbogbo àwọn àfikún

Gba atokọ gbogbo awọn afẹyinti kọja awọn olupin rẹ.

Àwọn Ìbéèrè Pàtàkì

Pílámẹ́rà Irú Ti a nilo Àpèjúwe
server_id integer Rárá Àlẹ̀mọ́ àwọn àtìlẹ́yìn nípasẹ̀ ID olupin
backup_type string Rárá Àlẹ̀mọ́ nípa irú: manual , automatic

Àpẹẹrẹ Ìbéèrè

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

Àpẹẹrẹ Ìdáhùn

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

Àwọn Kóòdù Ipò Ìdáhùn

200 A ṣe àṣeyọrí láti gba àkójọ àfikún padà
401 Àìní àṣẹ - Àmì ìdánilójú tí kò tọ́ tàbí tí kò sí mọ́
Ifiranṣẹ /api/v1/backups/

Ṣẹ̀dá Àfikún Ọwọ́

Ṣẹ̀dá àfikún oníṣẹ́-alágbára kan. Àfikún oníṣẹ́-alágbára kì í parí láìfọwọ́ṣe.

Ìbéèrè fún Àwọn Ìwọ̀n Ara

Pílámẹ́rà Irú Ti a nilo Àpèjúwe
server_id integer Bẹ́ẹ̀ni ID ti olupin si afẹyinti
description string Rárá Àpèjúwe àṣàyàn fún àfikún

Àpẹẹrẹ Ìbéèrè

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

Àpẹẹrẹ Ìdáhùn

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

Àwọn Kóòdù Ipò Ìdáhùn

201 Ṣiṣẹda afẹyinti bẹrẹ ni aṣeyọri
400 Ìbéèrè Tí Kò Dáa - Àwọn pàrámítà tí kò tọ́ tàbí ìbéèrè tí kò dáa
401 Àìní àṣẹ - Àmì ìdánilójú tí kò tọ́ tàbí tí kò sí mọ́
404 A ko ri - olupin ko si
Àkíyèsí: O le ni o pọju awọn afẹyinti afọwọṣe 10 fun olupin kọọkan. Awọn afẹyinti alaifọwọda ni a tọju da lori eto imulo idaduro afẹyinti ti eto rẹ (nigbagbogbo ọjọ 7-30).
PARÍPÁRÁ /api/v1/backups/{backup_id}/

Pa Àfikún rẹ́

Pa àfikún rẹ́ pátápátá. A kò le dá ìgbésẹ̀ yìí padà.

Àwọn Pílámítà Ọ̀nà

Pílámẹ́rà Irú Ti a nilo Àpèjúwe
backup_id integer Bẹ́ẹ̀ni ID afẹyinti alailẹgbẹ

Àpẹẹrẹ Ìbéèrè

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

Àwọn Kóòdù Ipò Ìdáhùn

204 Àfikún ti paarẹ ní àṣeyọrí
401 Àìní àṣẹ - Àmì ìdánilójú tí kò tọ́ tàbí tí kò sí mọ́
404 A ko ri - Afẹyinti ko si
Ìkìlọ̀: Pípa àfikún mọ́ jẹ́ ohun tí ó wà títí láé, a kò sì le dá a padà. Rí i dájú pé o kò nílò àfikún yìí mọ́ kí o tó pa á rẹ́.

Nmu pada lati Awọn Afẹyinti

Láti mú olupin kan pada láti inú àfikún, lo ìparí àtúnṣe Servers API :

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

Fun alaye ni kikun nipa atunṣe olupin, wo Àwọn ìwé API fún àwọn olupin.

Àwọn Ìlànà Àfikún Tó Dáa Jùlọ