Advertisement
ExamV1

CapMonster Balance Checker

Mar 18th, 2023 (edited)
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. #A balance checker for https://capmonster.cloud/en/
  2.  
  3. import time
  4. import requests
  5. import os
  6.  
  7. while 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.  
  17. print(f"Press Enter to refresh your balance.\n You currently have ${balance:.3f}")
  18.  
  19. while 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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement