· 2 years ago · Mar 18, 2023, 08:50 PM
1#A balance checker for https://capmonster.cloud/en/
2
3import time
4import requests
5import os
6
7while True:
8 api_key = input("Enter your CapMonster API key: ")
9 try:
10 response = requests.post("https://api.capmonster.cloud/getBalance", json={"clientKey": api_key}).json()
11 if response['errorId'] == 0:
12 balance = response['balance']
13 break
14 except:
15 print("Incorrect API key. Please try again.")
16
17print(f"Press Enter to refresh your balance.\n You currently have ${balance:.3f}")
18
19while True:
20 command = input()
21 if command.lower() == "quit":
22 break
23 elif command == "":
24 print("Refreshing balance", end="", flush=True)
25 for _ in range(6):
26 time.sleep(0.1)
27 print(".", end="", flush=True)
28 print()
29 os.system("cls" if os.name == "nt" else "clear")
30 try:
31 response = requests.post("https://api.capmonster.cloud/getBalance", json={"clientKey": api_key}).json()
32 if response['errorId'] == 0:
33 balance = response['balance']
34 print(f"Your balance is: {balance:.3f}")
35 else:
36 print("Failed to get balance.")
37 except:
38 print("Incorrect API key. Please try again.")
39 print("Press Enter to refresh the balance")
40 else:
41 print("Invalid command.")
42