VPS.org API

REST API 文件

位置 API

列出您可以部署 VPS 的位置。 当您创建服务器时, 将位置的代号作为位置(_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 位置标识符。 创建服务器时使用它作为位置_ id 。
name string 人类可读地点名称
country_name string 地点所在的国家
country_code string ISO 3166-1 Alpha-2国家代码,大号
is_active boolean 是否正在接受新服务器

响应状态码

200 已成功检索位置列表
403 遗失或无效 API 牌标牌, 或者该牌牌缺少必需的许可
得到 /api/v1/locations/{id}/

获得位置

以其 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 的全世界客户。 总是读取地点端点, 而不是硬码代号, 所以您在添加新位置时会选择新的位置 。