# getBalance

Returns the account balance in US dollars.

`POST https://unlock-api.com/getBalance`

## Request parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `clientKey` | String | Yes | Your API key, 32 characters, from the account page. |

## Request

```json
{
  "clientKey": "YOUR_API_KEY"
}
```

## Response

### Success

```json
{
  "errorId": 0,
  "balance": 42.5
}
```

## Response fields

| Name | Type | Description |
|---|---|---|
| `errorId` | Integer | 0 when the request worked, 1 when it did not. |
| `balance` | Number | Balance in US dollars. |

## Code samples

### cURL

```bash
curl -s https://unlock-api.com/getBalance \
  -H "Content-Type: application/json" \
  -d '{"clientKey":"YOUR_API_KEY"}'
```

### Python

```python
import requests

r = requests.post("https://unlock-api.com/getBalance", json={
    "clientKey": "YOUR_API_KEY"
}).json()
print(r)
```

### Node.js

```javascript
const r = await fetch("https://unlock-api.com/getBalance", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({
    "clientKey": "YOUR_API_KEY"
  }),
}).then((res) => res.json());
console.log(r);
```

## Errors this method can return

- `ERROR_KEY_DOES_NOT_EXIST`: The key is wrong. Copy it again from the account page. (in.php and res.php: ERROR_WRONG_USER_KEY)
- `ERROR_IP_NOT_ALLOWED`: The request came from an IP that is not on the account's allow list. Add the IP on the account page.
- `ERROR_IP_BANNED`: This account is blocked. Contact support from the account page.
- `ERROR_TOO_MANY_REQUESTS`: Too many requests. Slow down result checks to every 5 seconds.
