VPS.org API

REST API 문서화

계정 API

계정 프로필 및 API 토큰 정보 검색 API 토큰과 연결된 계정 및 권한을 식별하는 데 유용합니다.

엔드포인트 1 엔드포인트
기본 경로 /api/v1/account
얻다 /api/v1/account/me/

계정 및 토큰 정보 가져오기

요청에 사용된 API 토큰에 대한 계정 프로필 메타데이터 및 토큰 범위/권한을 반환합니다. 여러 API 토큰을 관리하고 토큰이 어떤 계정에 속하는지 및 어떤 권한을 가지는지 식별해야 할 때 유용합니다.

입증

유효한 API 토큰이 필요합니다. 권한 범위에 관계없이 모든 활성 토큰이 이 엔드포인트에 액세스할 수 있습니다.

예시 요청

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

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

response = requests.get(url, headers=headers)
data = response.json()

print(f"Account: {data['account']['email']}")
print(f"Token: {data['token']['name']}")
print(f"Permissions: {data['token']['permissions']}")
const response = await fetch('https://admin.vps.org/api/v1/account/me/', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer YOUR_API_TOKEN',
    'Content-Type': 'application/json'
  }
});

const data = await response.json();
console.log(`Account: ${data.account.email}`);
console.log(`Token: ${data.token.name}`);
console.log(`Permissions:`, data.token.permissions);
$ch = curl_init('https://admin.vps.org/api/v1/account/me/');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_TOKEN',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

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

echo "Account: " . $data['account']['email'] . "\n";
echo "Token: " . $data['token']['name'] . "\n";
echo "Permissions: " . implode(', ', $data['token']['permissions']) . "\n";

예시 답변

{
  "account": {
    "email": "john@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "company_name": "Acme Inc.",
    "created_at": "2024-06-15"
  },
  "token": {
    "name": "Production Deploy Key",
    "permissions": [
      "servers:list",
      "servers:create",
      "servers:power",
      "dns:*"
    ],
    "created_at": "2025-01-10T14:30:00Z",
    "last_used_at": "2025-02-11T08:45:12Z",
    "expires_at": null,
    "is_expired": false
  }
}

응답 필드

account object
필드 유형 설명
email string Account email address
first_name string | null Account holder's first name
last_name string | null Account holder's last name
company_name string | null Company name (if set)
created_at date Account creation date (YYYY-MM-DD)
token object
필드 유형 설명
name string Name assigned to this API token
permissions array List of permission strings (e.g. servers:list, dns:*). See Authentication docs for permission format.
created_at datetime When the token was created (ISO 8601)
last_used_at datetime | null Last time the token was used for authentication
expires_at datetime | null Token expiration date (null if no expiration)
is_expired boolean Whether the token has expired

응답 상태 코드

200 Successfully retrieved account and token information
401 Unauthorized - Invalid, expired, or missing API token

일반적인 사용 사례

토큰 소유자 식별

다른 애플리케이션에서 여러 개의 API 토큰을 관리할 때 이 엔드포인트를 사용하여 토큰이 어느 계정에 속하는지 확인합니다.

# Check which account this token is associated with
response = requests.get(
    "https://admin.vps.org/api/v1/account/me/",
    headers={"Authorization": f"Bearer {api_token}"}
)
account = response.json()["account"]
print(f"This token belongs to: {account['email']}")

토큰 권한 확인

API 호출을 하기 전에 현재 토큰에 어떤 권한이 있는지 확인하세요.

# Check token permissions before performing an action
response = requests.get(
    "https://admin.vps.org/api/v1/account/me/",
    headers={"Authorization": f"Bearer {api_token}"}
)
permissions = response.json()["token"]["permissions"]

if "servers:create" in permissions or "servers:*" in permissions:
    # Token has permission to create servers
    create_server()
else:
    print("Token does not have servers:create permission")

토큰 만료 모니터링

토큰이 만료될지 확인하세요.

from datetime import datetime

response = requests.get(
    "https://admin.vps.org/api/v1/account/me/",
    headers={"Authorization": f"Bearer {api_token}"}
)
token_info = response.json()["token"]

if token_info["expires_at"]:
    expires = datetime.fromisoformat(token_info["expires_at"])
    days_left = (expires - datetime.now()).days
    if days_left < 7:
        print(f"Warning: Token expires in {days_left} days")
else:
    print("Token has no expiration date")

권한 참조

권한은 형식을 따릅니다 resource:action. 사용 resource:* 리소스에 대한 완전한 액세스를 위해, 또는 *:* 완전한 API 액세스를 위한 옵션

자원 사용 가능한 동작
servers list, create, update, delete, power, backup, snapshot, resize, *
domains list, search, update, renew, *
dns list, create, update, delete, *
snapshots list, delete, *
backups list, *
ssh-keys list, create, delete, *
plans list, *
locations list, *
deployments list, create, delete, *
billing list, *
Manage your tokens: Create, edit, and revoke API tokens at admin.vps.org/account/developers/