· 2 years ago · Mar 08, 2023, 12:00 AM
1#This is a simple python script that allows you to check the balance of any valid 2Captcha API key.
2#Check out it on replit! https://replit.com/@ExamV1/2captcha-Balance-Checker?v=1
3
4import requests
5import os
6import time
7
8def get_balance(api_key):
9 url = f"https://2captcha.com/res.php?key={api_key}&action=getbalance"
10 response = requests.get(url)
11 if response.status_code == 200:
12 if response.text.startswith("ERROR"):
13 return None
14 else:
15 return float(response.text)
16 else:
17 return None
18
19while True:
20 api_key = input("Enter your 2captcha API key: ")
21 balance = get_balance(api_key)
22 if balance is not None:
23 break
24 else:
25 print("Incorrect API key. Please try again.")
26
27print(f"Press Enter to refresh your balance.\n You cureently have ${balance:.2f}")
28
29while True:
30 command = input()
31 if command.lower() == "quit":
32 break
33 elif command == "":
34 print("Refreshing balance", end="", flush=True)
35 for _ in range(6):
36 time.sleep(0.1)
37 print(".", end="", flush=True)
38 print()
39 os.system("cls" if os.name == "nt" else "clear")
40 balance = get_balance(api_key)
41 if balance is not None:
42 print(f"Your balance is: ${balance:.2f}")
43 else:
44 print("Failed to get balance. Please check your API key and try again.")
45 print("Press Enter to refresh the balance")