# getBalance ตรวจสอบยอดคงเหลือ

> POST /getBalance ตรวจสอบยอดคงเหลือของบัญชี (พอยต์ 1,000 พอยต์ = ¥1) รวมถึงยอดส่วนแบ่งรายได้นักพัฒนาและรางวัลแนะนำเพื่อน ไม่หักพอยต์ และใช้ตรวจสอบ clientKey ได้

Source: https://docs.yescaptcha.com/th/api/get-balance/ · Last verified: 2026-10-15

> This page was machine-translated from the Chinese version. If anything differs, the Chinese version prevails: https://docs.yescaptcha.com/zh/api/get-balance/

`getBalance` คืนค่าพอยต์คงเหลือของบัญชี (1,000 พอยต์ = ¥1) รวมถึงยอดส่วนแบ่งรายได้นักพัฒนาและรางวัลแนะนำเพื่อน (หน่วยเป็นหยวน) ไม่หักพอยต์ จึงมักใช้ตรวจสอบว่า `clientKey` ถูกต้องหรือไม่

- POST `https://api.yescaptcha.com/getBalance` (endpoint ทั่วโลก)
- POST `https://cn.yescaptcha.com/getBalance` (endpoint จีน)

## พารามิเตอร์ของคำขอ

| ฟิลด์ | ประเภท | จำเป็น | คำอธิบาย |
| --- | --- | --- | --- |
| `clientKey` | string | ใช่ | ClientKey ของบัญชี |

```json
{
  "clientKey": "YOUR_CLIENT_KEY"
}
```

## ผลลัพธ์ที่ส่งกลับ

```json
{
  "errorId": 0,
  "balance": 1071810,
  "softBalance": 36.0098,
  "inviteBalance": 0,
  "inviteBy": 0
}
```

| ฟิลด์ | ประเภท | คำอธิบาย |
| --- | --- | --- |
| `balance` | integer | ยอดคงเหลือของบัญชี หน่วยเป็นพอยต์ (1,000 พอยต์ = ¥1) ต้องมากกว่า 10 พอยต์จึงจะสร้างงานได้ |
| `softBalance` | number | ยอดส่วนแบ่งรายได้นักพัฒนา หน่วยเป็นหยวน ดู [ส่วนแบ่งรายได้นักพัฒนา](https://docs.yescaptcha.com/th/account/developer.md) |
| `inviteBalance` | number | ยอดรางวัลแนะนำเพื่อน หน่วยเป็นหยวน ดู [รางวัลแนะนำเพื่อน](https://docs.yescaptcha.com/th/account/referral.md) |
| `inviteBy` | integer | ID ผู้ใช้ของผู้ที่แนะนำคุณให้สมัครสมาชิก หากไม่มีจะเป็น 0 |
| `keyQuotaRemaining` | integer | ขีดจำกัดการใช้จ่ายที่เหลือของ `clientKey` นี้ในรอบปัจจุบัน หน่วยเป็นพอยต์ ฟิลด์นี้มีเฉพาะ `clientKey` ที่ตั้งขีดจำกัดไว้ โดยในกรณีนี้ `balance` จะเป็นค่าที่น้อยกว่าระหว่างยอดคงเหลือของบัญชีกับขีดจำกัดที่เหลือ ส่วน `clientKey` ที่ไม่ได้ตั้งขีดจำกัดจะไม่มีฟิลด์นี้ |

หาก `clientKey` ไม่ถูกต้อง จะคืนค่า `ERROR_KEY_DOES_NOT_EXIST` หาก `clientKey` ตั้งไวต์ลิสต์ IP ไว้และ IP ที่ส่งคำขอไม่อยู่ในรายการ จะคืนค่า `ERROR_KEY_IP_NOT_ALLOWED` `getBalance` ได้รับผลจาก [หยุดชั่วคราวอัตโนมัติ](https://docs.yescaptcha.com/th/api/rate-limits.md) โดยระหว่างที่ถูกหยุดชั่วคราวจะคืนค่า `ERROR_IP_BLOCKED_5MIN`

## ตัวอย่าง

**curl**

get-balance.sh

```bash
#!/usr/bin/env bash
# Check the balance. getBalance is free and is a quick way to verify your clientKey
set -euo pipefail
curl -s https://api.yescaptcha.com/getBalance \
  -H 'Content-Type: application/json' \
  -d "{\"clientKey\": \"${YESCAPTCHA_CLIENT_KEY}\"}"
echo
```

**Python**

get_balance.py

```python
"""Check the balance. getBalance is free and is a quick way to verify your clientKey."""
import os

import requests

CLIENT_KEY = os.environ["YESCAPTCHA_CLIENT_KEY"]

r = requests.post(
    "https://api.yescaptcha.com/getBalance",
    json={"clientKey": CLIENT_KEY},
    timeout=30,
)
data = r.json()
if data.get("errorId"):
    # e.g. ERROR_KEY_DOES_NOT_EXIST when the clientKey is wrong
    print("error:", data.get("errorCode"), data.get("errorDescription"))
else:
    print("balance (points):", data["balance"])
```

**Node.js**

get-balance.mjs

```js
// Check the balance. getBalance is free and is a quick way to verify your clientKey. Node.js 18+
const CLIENT_KEY = process.env.YESCAPTCHA_CLIENT_KEY;

const res = await fetch('https://api.yescaptcha.com/getBalance', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ clientKey: CLIENT_KEY }),
});
const data = await res.json();
if (data.errorId) {
  // e.g. ERROR_KEY_DOES_NOT_EXIST when the clientKey is wrong
  console.log('error:', data.errorCode, data.errorDescription);
} else {
  console.log('balance (points):', data.balance);
}
```
