VPS.org API

Dokumentasi API REST

API Lokasi

Senarai lokasi di mana anda boleh laksanakan VPS. Serahkan id lokasi sebagai location_id bila anda cipta pelayan.

Titik akhir 2 endpoints
Laluan Asas /api/v1/locations
DAPATKAN /api/v1/locations/

Senaraikan Semua Lokasi

Dapatkan senarai semua lokasi pusat data yang ada di mana anda boleh pasang pelayan VPS.

Contoh Permintaan

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

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

response = requests.get(url, headers=headers)
print(response.json())
const response = await fetch('https://admin.vps.org/api/v1/locations/', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

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

$response = curl_exec($ch);
$locations = json_decode($response, true);
curl_close($ch);

Contoh Respons

{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 1,
      "name": "New Jersey",
      "country_name": "United States",
      "country_code": "US",
      "is_active": true
    }
  ]
}

Medan Respons

Medan Jenis Huraian
id integer Pengenalpasti lokasi. Gunakannya sebagai location_id bila mencipta pelayan.
name string Nama lokasi boleh baca manusia
country_name string Negara lokasi adalah di
country_code string Kod negara ISO 3166-1 alpha-2, huruf besar
is_active boolean Samada lokasi menerima pelayan baru

Kod Status Respons

200 Senarai lokasi berjaya diambil
403 Token API hilang atau tidak sah, atau token tidak mempunyai keizinan yang diperlukan
DAPATKAN /api/v1/locations/{id}/

Dapatkan Lokasi

Dapatkan lokasi tunggal mengikut idnya. Jawapan adalah satu objek lokasi dengan medan di atas.

curl -X GET "https://admin.vps.org/api/v1/locations/1/" \
  -H "Authorization: Bearer YOUR_API_TOKEN"
{
  "id": 1,
  "name": "New Jersey",
  "country_name": "United States",
  "country_code": "US",
  "is_active": true
}

Dimana Pelayan Anda Berlaku

Setiap pelayan VPS.org kini berjalan di lokasi kami New Jersey, USA, yang melayani pelanggan di seluruh dunia melalui IPv4 dan IPv6. Sentiasa baca titik akhir lokasi bukannya hardcoding id, jadi integrasi anda mengambil lokasi baru bila ia ditambah.