Check Your Balance via the API
You can get your current balance at any moment without opening the dashboard. This is handy for scripts that run for a long time: check the balance before a large batch, or stop the script and send yourself a notification when the money is about to run out.
Request
Send a GET request to http://api2.cap.guru/res.php with two parameters:
action: alwaysgetbalancekey: your API key
http://api2.cap.guru/res.php?action=getbalance&key=YOUR_APIKEYThe response contains your current balance.
Examples
cURL:
bash
curl "http://api2.cap.guru/res.php?action=getbalance&key=YOUR_APIKEY"Python:
python
import requests
r = requests.get(
"http://api2.cap.guru/res.php",
params={"action": "getbalance", "key": "YOUR_APIKEY"},
timeout=30,
)
print("Balance:", r.text)If the key is wrong, the API returns an error code instead of the balance. You can look it up on the error codes page.