Gba àwọn ìròyìn àwọn kọ́́ǹpútà àti àwọn ìròyìn àwọn tókè API. Lòòròlò fún ìṣàfihàn àwọn kọ́́ǹpútà àti àwọn ìwọ̀n tí a bá sopọ̀ sí tókè API.
Ń bọ́ àwọn àkọlé àwọn àkọlé àwọn kọ́́ǹpútà kọ́́ǹpútà àti àwọn ìwọ̀n/ìwọ̀n àwọn tókè fún tókè API tí a lò nínú ìtàn. O lò láti mọ̀ pé o lè ṣakoso tókè API àwọn ìwọ̀n àwọn tókè API àti àwọn ìwọ̀n àwọn kọ́́ǹpútà tí tókè náà jẹ́.
Ǹtí tókè API tó yẹ. Àwọn tókè tó dá lórí ìṣàfarawé ìparí iṣẹ́ lè gba ìjánu-ìsún yìí láti inú àwọn ìṣẹ̀dá àwọn ìṣẹ̀dá rẹ̀.
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| Àwọn Ààyè-iṣẹ́ | Irú | Àwọn Àkọlé |
|---|---|---|
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| Àwọn Ààyè-iṣẹ́ | Irú | Àwọn Àkọlé |
|---|---|---|
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 |
Tí o bá n páráwọ́lú àwọn tókè API àwọn ìṣàmúlò-ètò mìíràn, ló àwọn ààtò ìparí yìí láti ṣàyẹwo àwọn àwọn kọ́́ntà tí tókè náà jẹ́:
# 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']}")
Ààyè àwọn ìṣẹ̀dá API, ṣàyẹwo àwọn ìwọ̀n tí tókè lọ́wọ́lọ́wọ́ náà ni:
# 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")
Ṣayẹwo tí tokè rẹ tí n bọ́ ìgbà ìparí iṣẹ́:
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")
Àwọn ìkúndùǹ láti lágbára ìṣàfarawé resource:action. Lo resource:* fún ìṣàfihàn ìpéwọ̀n fún ààyè-iṣẹ́ kan, tàbí *:* fun ìṣàfihàn API ìparí.
| Àwọn Ìṣàmúlò-ètò | Àwọn Ìṣàmúlò-ètò Tí Wá |
|---|---|
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, * |