REST API v1 · 開發者 · API 參考
銀行 API 參考
BotGG REST API v1 的所有 4 個 銀行 端點:範圍、參數、欄位、錯誤,以及可直接執行的 curl、JavaScript 與 Python 範例。
開發者文件
本頁目錄
端點
路徑皆相對於 https://console.botgg.app/api/v1。請以 Authorization: Bearer botgg_… 傳送你的 API 金鑰,ID 皆為字串。
| 端點 | 範圍 | 說明 |
|---|---|---|
GET/guilds/{guildId}/bank/members/{userId} | bank:read | Get a member’s balance |
GET/guilds/{guildId}/bank/members/{userId}/transactions | bank:read | List a member’s transactions |
POST/guilds/{guildId}/bank/members/{userId}/transactions | bank:write | Add to or remove from a member’s balance |
GET/guilds/{guildId}/bank/leaderboard | bank:read | Top balances |
除了下方各自的錯誤外,每個端點還可能回傳這些常見錯誤:
Get a member’s balance
GET/guilds/{guildId}/bank/members/{userId}
Members without an account yet get the server’s starting balance.
需要在伺服器上啟用此功能: 銀行
| 名稱 | 位置 | 類型 | 必填 | 說明 |
|---|---|---|---|---|
guildId | 路徑 | string | 是 | 你的伺服器 ID · Discord ID(字串) |
userId | 路徑 | string | 是 | 成員的 Discord 使用者 ID · Discord ID(字串) |
回應
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
userId | string | 是 | |
balance | integer | 是 | |
currency | object | 是 | |
currency.name | string | 是 | |
currency.plural | string | 是 | |
currency.emoji | string | null | 是 |
{
"userId": "876543210987654321",
"balance": 1350,
"currency": {
"name": "Example",
"plural": "example",
"emoji": "🪙"
}
}範例
curl -s "https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321" \
-H "Authorization: Bearer $BOTGG_API_KEY"// Node.js 18+ (built-in fetch) — on your server, never in a browser
const res = await fetch('https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.BOTGG_API_KEY}`,
},
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`);
console.log(data);import os
import requests
res = requests.get(
"https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321",
headers={
"Authorization": f"Bearer {os.environ['BOTGG_API_KEY']}",
},
timeout=10,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {data['error']}: {data['message']}")
print(data)錯誤
| HTTP | 代碼 |
|---|---|
| 409 | BANK_DISABLED |
| 503 | SERVICE_UNAVAILABLE |
List a member’s transactions
GET/guilds/{guildId}/bank/members/{userId}/transactions
Newest first. Pass before=<nextCursor> for the next page.
需要在伺服器上啟用此功能: 銀行
| 名稱 | 位置 | 類型 | 必填 | 說明 |
|---|---|---|---|---|
guildId | 路徑 | string | 是 | 你的伺服器 ID · Discord ID(字串) |
userId | 路徑 | string | 是 | 成員的 Discord 使用者 ID · Discord ID(字串) |
limit | 查詢字串 | integer | 否 | 1–100 · 預設值 25 |
before | 查詢字串 | integer | 否 | 至少 1 |
回應
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
items | array of object | 是 | |
items[].id | integer | 是 | |
items[].type | string | 是 | |
items[].amount | integer | 是 | |
items[].balanceAfter | integer | 是 | |
items[].reason | string | null | 是 | |
items[].counterpartyId | string | null | 是 | |
items[].createdAt | string | 是 | |
nextCursor | string | null | 是 |
{
"items": [
{
"id": 98765,
"type": "example",
"amount": 100,
"balanceAfter": 1350,
"reason": "Tournament prize",
"counterpartyId": "234567890123456789",
"createdAt": "2026-10-07T12:00:00.000Z"
}
],
"nextCursor": "98700"
}範例
curl -s "https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321/transactions?limit=25" \
-H "Authorization: Bearer $BOTGG_API_KEY"// Node.js 18+ (built-in fetch) — on your server, never in a browser
const res = await fetch('https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321/transactions?limit=25', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.BOTGG_API_KEY}`,
},
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`);
console.log(data);import os
import requests
res = requests.get(
"https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321/transactions",
headers={
"Authorization": f"Bearer {os.environ['BOTGG_API_KEY']}",
},
params={
"limit": 25,
},
timeout=10,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {data['error']}: {data['message']}")
print(data)錯誤
| HTTP | 代碼 |
|---|---|
| 409 | BANK_DISABLED |
| 503 | SERVICE_UNAVAILABLE |
Add to or remove from a member’s balance
POST/guilds/{guildId}/bank/members/{userId}/transactions
Same rules as a banker change. Logged in the Bank ledger (type api) and the Bank log channel.
需要在伺服器上啟用此功能: 銀行
| 名稱 | 位置 | 類型 | 必填 | 說明 |
|---|---|---|---|---|
guildId | 路徑 | string | 是 | 你的伺服器 ID · Discord ID(字串) |
userId | 路徑 | string | 是 | 成員的 Discord 使用者 ID · Discord ID(字串) |
Idempotency-Key | 標頭 | string | 否 | 選填。傳送一個唯一值(UUID),重試時沿用同一個值,變更就只會發生一次。 運作方式 |
請求內容
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
type | string | 是 | add = credit, remove = debit 其中之一 add, remove |
amount | integer | 是 | 1–1,000,000,000,000 |
reason | string | null | 否 | Shown in the Bank ledger and log 最多 200 個字元 |
回應
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
transactionId | integer | 是 | |
userId | string | 是 | |
type | string | 是 | 其中之一 add, remove |
amount | integer | 是 | |
previousBalance | integer | 是 | |
balance | integer | 是 | |
createdAt | string | 是 |
{
"transactionId": 98765,
"userId": "876543210987654321",
"type": "add",
"amount": 100,
"previousBalance": 1250,
"balance": 1350,
"createdAt": "2026-10-07T12:00:00.000Z"
}範例
curl -s -X POST "https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321/transactions" \
-H "Authorization: Bearer $BOTGG_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"type":"add","amount":100,"reason":"Tournament prize"}'// Node.js 18+ (built-in fetch) — on your server, never in a browser
const res = await fetch('https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321/transactions', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.BOTGG_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(), // reuse it when you retry this request
},
body: JSON.stringify({
type: 'add',
amount: 100,
reason: 'Tournament prize',
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`);
console.log(data);import os, uuid
import requests
res = requests.post(
"https://console.botgg.app/api/v1/guilds/123456789012345678/bank/members/876543210987654321/transactions",
headers={
"Authorization": f"Bearer {os.environ['BOTGG_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()), # reuse it when you retry this request
},
json={
"type": "add",
"amount": 100,
"reason": "Tournament prize",
},
timeout=10,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {data['error']}: {data['message']}")
print(data)錯誤
Top balances
GET/guilds/{guildId}/bank/leaderboard
需要在伺服器上啟用此功能: 銀行
| 名稱 | 位置 | 類型 | 必填 | 說明 |
|---|---|---|---|---|
guildId | 路徑 | string | 是 | 你的伺服器 ID · Discord ID(字串) |
limit | 查詢字串 | integer | 否 | 1–100 · 預設值 10 |
回應
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
items | array of object | 是 | |
items[].rank | integer | 是 | |
items[].userId | string | 是 | |
items[].balance | integer | 是 | |
currency | object | 是 | |
currency.name | string | 是 | |
currency.plural | string | 是 | |
currency.emoji | string | null | 是 |
{
"items": [
{
"rank": 1,
"userId": "876543210987654321",
"balance": 1350
}
],
"currency": {
"name": "Example",
"plural": "example",
"emoji": "🪙"
}
}範例
curl -s "https://console.botgg.app/api/v1/guilds/123456789012345678/bank/leaderboard?limit=10" \
-H "Authorization: Bearer $BOTGG_API_KEY"// Node.js 18+ (built-in fetch) — on your server, never in a browser
const res = await fetch('https://console.botgg.app/api/v1/guilds/123456789012345678/bank/leaderboard?limit=10', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.BOTGG_API_KEY}`,
},
});
const data = await res.json();
if (!res.ok) throw new Error(`${res.status} ${data.error}: ${data.message}`);
console.log(data);import os
import requests
res = requests.get(
"https://console.botgg.app/api/v1/guilds/123456789012345678/bank/leaderboard",
headers={
"Authorization": f"Bearer {os.environ['BOTGG_API_KEY']}",
},
params={
"limit": 10,
},
timeout=10,
)
data = res.json()
if not res.ok:
raise RuntimeError(f"{res.status_code} {data['error']}: {data['message']}")
print(data)錯誤
| HTTP | 代碼 |
|---|---|
| 409 | BANK_DISABLED |
| 503 | SERVICE_UNAVAILABLE |