Rotating Apify API key manager. Returns the least-recently-used active Apify key from the ColdCore database. Use before any Apify API call to get a fresh key with available credits.
Get a rotating Apify API key from the ColdCore database. Keys are rotated by least-recently-used with balance checking.
Get next available API key:
python3 ~/.openclaw/workspace/skills/apify-keys/scripts/get_key.py
Get key as JSON (for piping to other scripts):
python3 ~/.openclaw/workspace/skills/apify-keys/scripts/get_key.py --json
Check balance on a specific key:
python3 ~/.openclaw/workspace/skills/apify-keys/scripts/get_key.py --check-balance --key "apify_api_xxxxx"
python3 ~/.openclaw/workspace/skills/apify-keys/scripts/get_key.py --list
scrape_sm_accounts for active Apify accountslast_used timestamp (least recently used)last_used to current timestamp after selectionThe script reads database credentials from these environment variables (falls back to defaults):
COLDCORE_HOST — MySQL hostCOLDCORE_USER — MySQL usernameCOLDCORE_PASS — MySQL passwordCOLDCORE_DB — Database name (default: lead_generator)Default mode: prints just the API key string (for easy piping)
apify_api_xxxxx
JSON mode (--json):
{"id": 68, "api_key": "apify_api_xxxxx", "email": "[email protected]", "balance": 4.95}
Other skills that need Apify access should call this script to get a key:
APIFY_KEY=$(python3 ~/.openclaw/workspace/skills/apify-keys/scripts/get_key.py)
# Then use $APIFY_KEY in your API calls
Or in Python:
import subprocess
result = subprocess.run(
["python3", os.path.expanduser("~/.openclaw/workspace/skills/apify-keys/scripts/get_key.py"), "--json"],
capture_output=True, text=True
)
key_data = json.loads(result.stdout)
api_key = key_data["api_key"]