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/