VPS.org API

ឯកសារ REST API

API ទីតាំង

រាយ​ទីតាំង​ដែល​អ្នក​អាច​បញ្ជូន VPS ។ ផ្ដល់​លេខ​សម្គាល់​ទីតាំង​ជា location_ id ពេល​អ្នក​បង្កើត​ម៉ាស៊ីន​បម្រើ ។

ចំណុចបញ្ចប់ 2 endpoints
ផ្លូវមូលដ្ឋាន /api/v1/locations
ទទួលបាន /api/v1/locations/

រាយបញ្ជីទីតាំងទាំងអស់

យក​បញ្ជី​នៃ​ទីតាំង​មជ្ឈមណ្ឌល​ទិន្នន័យ​ដែល​មាន​ទាំងអស់​ដែល​អ្នក​អាច​បញ្ជូន​ម៉ាស៊ីន​បម្រើ VPS ។

សំណើឧទាហរណ៍

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

ឧទាហរណ៍នៃការឆ្លើយតប

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

វាលឆ្លើយតប

វាល ប្រភេទ សេចក្ដី​ពិពណ៌នា
id integer ឧបករណ៍​កំណត់​អត្តសញ្ញាណ​ទីតាំង ។ ប្រើ​វា​ជា location_ id ពេល​បង្កើត​ម៉ាស៊ីន​បម្រើ ។
name string ឈ្មោះ​ទីតាំង​ដែល​អាច​អាន​បាន​ដោយ​មនុស្ស
country_name string ប្រទេស​ដែល​ទីតាំង​ស្ថិត​នៅ
country_code string កូដ​ប្រទេស ISO 3166- 1 alpha-2តួអក្សរ​ធំ
is_active boolean ថា​តើ​ទីតាំង​ទទួល​យក​ម៉ាស៊ីន​បម្រើ​ថ្មី​ឬ​ទេ

លេខកូដស្ថានភាពឆ្លើយតប

200 បានទាញយកបញ្ជីទីតាំងដោយជោគជ័យ
403 បាត់ ឬ​មិន​ត្រឹមត្រូវ API token ឬ​ token ខ្វះ​សិទ្ធិ​ដែល​ត្រូវការ
ទទួលបាន /api/v1/locations/{id}/

យក​ទីតាំង

យក​ទីតាំង​តែ​មួយ​ដោយ​លេខ​សម្គាល់​របស់​វា ។ ការ​ឆ្លើយតប​គឺ​វត្ថុ​ទីតាំង​មួយ​ជាមួយ​វាល​ខាង​លើ ។

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
}

កន្លែង​ដែល​ម៉ាស៊ីន​បម្រើ​របស់​អ្នក​រត់

ម៉ាស៊ីនបម្រើ VPS.org ទាំងអស់បច្ចុប្បន្នកំពុងរត់នៅក្នុងរដ្ឋញូវជឺស៊ីរបស់យើង, ទីតាំងសហរដ្ឋអាមេរិក, ដែលផ្តល់ជូនអតិថិជននៅទូទាំងពិភពលោកតាមរយៈ IPv4 និង IPv6. តែងតែអានចំណុចបញ្ចប់ទីតាំងជំនួសឱ្យ hardcoding លេខសម្គាល់មួយ, ដូច្នេះការរួមបញ្ចូលរបស់អ្នក picks up new locations when they are added.