VPS.org API

Dokumentacja REST API

API planów

Wyświetl plany serwera, które można rozmieszczyć, z ich zasobami i cenami. Przekaż planu uuid jako plan_ uuid, gdy tworzysz lub zmieniasz rozmiar serwera.

Punkty końcowe 2
Ścieżka bazowa /api/v1/plans
DOSTAWAĆ /api/v1/plans/

Wyświetl wszystkie plany

Zwraca każdy aktywny plan, najtańszy najpierw. Lista nie ma filtrów i aktualnie pasuje na jednej stronie.

Wymagane zezwolenie: plans:list

Przykładowe żądanie

cURL
Python
JavaScript
PHP
curl -X GET "https://admin.vps.org/api/v1/plans/" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
import requests

url = "https://admin.vps.org/api/v1/plans/"
headers = {"Authorization": "Bearer YOUR_API_TOKEN"}

response = requests.get(url, headers=headers)
for plan in response.json()["results"]:
    print(plan["uuid"], plan["cpu"], plan["ram"], plan["ram_unit"], plan["monthly_price"])
const response = await fetch('https://admin.vps.org/api/v1/plans/', {
  headers: { 'Authorization': 'Bearer YOUR_API_TOKEN' }
});

const data = await response.json();
console.log(data.results);
$ch = curl_init('https://admin.vps.org/api/v1/plans/');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer YOUR_API_TOKEN']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$plans = json_decode(curl_exec($ch), true);
curl_close($ch);

Przykładowa odpowiedź

{
  "count": 12,
  "next": null,
  "previous": null,
  "results": [
    {
      "uuid": "ed0ac717-c26c-4d9b-a801-b170c4979028",
      "cpu": 1,
      "ram": 512,
      "ram_unit": "MB",
      "disk_space": 10,
      "disk_space_total": 10240,
      "transfer": 500,
      "transfer_unit": "GB",
      "includes_ipv4": false,
      "price": "2.50",
      "cpu_type_name": "Shared",
      "is_active": true,
      "hourly_price": "0.004",
      "monthly_price": "2.50",
      "is_gpu": false,
      "gpu_count": 0,
      "gpu_model": ""
    },
    {
      "uuid": "14186969-fbaf-43e1-9ab2-b1f1aeb66674",
      "cpu": 1,
      "ram": 2,
      "ram_unit": "GB",
      "disk_space": 25,
      "disk_space_total": 25600,
      "transfer": 1,
      "transfer_unit": "TB",
      "includes_ipv4": true,
      "price": "5.00",
      "cpu_type_name": "Shared",
      "is_active": true,
      "hourly_price": "0.007",
      "monthly_price": "5.00",
      "is_gpu": false,
      "gpu_count": 0,
      "gpu_model": ""
    }
  ]
}

Pola odpowiedzi

Pole Typ Opis
uuid string Identyfikator planu. Użyj go jako plan_uuid lub nowy_plan_uuid.
cpu integer Liczba wCPU
ram, ram_unit integer, string Ilość pamięci i jednostka (MB lub GB)
disk_space integer Rozmiar dysku w GB
disk_space_total integer Rozmiar dysku w MB
transfer, transfer_unit integer, string Miesięczny dodatek do przekazywania danych i jego jednostka (GB lub TB)
disk_space_unit string Jednostka dysku_ przestrzeni (GB)
includes_ipv4 boolean Czy plan zawiera publiczny adres IPv4. Plany bez nich są wyłącznie IPv6; IPv4 może być dodany na 2,00 dolarów/miesiąc.
monthly_price, price string Cena miesięczna w USD jako struna dziesiętna. cena jest tą samą wartością.
hourly_price string Cena godzinowa w USD jako struna dziesiętna
cpu_type_name string Typ procesora, np. Shared. Wysłany na plany bez typu procesora, jak np. plan GPU.
is_active boolean Zawsze wiersz w tej liście, ponieważ nieaktywne plany nie są zwracane
is_gpu, gpu_count, gpu_model boolean, integer, string Czy plan obejmuje specjalne GPU, ile, i który model
W odpowiedzi nie mówi się, czy plan zawiera adres IPv4. Plan 512 MB to tylko IPv6; inne plany bieżące obejmują IPv4. Porównaj z stroną cenową przed wyborem planu strony, która musi być dostępna w czasie IPv4.

Kody statusu odpowiedzi

200 Lista planów pomyślnie odzyskanych
403 Brak lub nieprawidłowy token API, lub token brakuje wymaganego pozwolenia
DOSTAWAĆ /api/v1/plans/{uuid}/

Uzyskaj szczegóły planu

Zwraca jeden aktywny plan z powyższymi polami. Nieaktywny lub nieznany uuid zwraca 404.

curl -X GET "https://admin.vps.org/api/v1/plans/ed0ac717-c26c-4d9b-a801-b170c4979028/" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
{
  "uuid": "ed0ac717-c26c-4d9b-a801-b170c4979028",
  "cpu": 1,
  "ram": 512,
  "ram_unit": "MB",
  "disk_space": 10,
  "disk_space_total": 10240,
  "transfer": 500,
  "transfer_unit": "GB",
  "includes_ipv4": false,
  "price": "2.50",
  "cpu_type_name": "Shared",
  "is_active": true,
  "hourly_price": "0.004",
  "monthly_price": "2.50",
  "is_gpu": false,
  "gpu_count": 0,
  "gpu_model": ""
}