UNLOCK API

हर भाषा के लिए क्लाइंट कोड

कोई पैकेज इंस्टॉल नहीं करना: हर क्लाइंट एक छोटी फाइल है जिसे आप अपने प्रोजेक्ट में कॉपी करते हैं। ये टास्क बनाते हैं, हर 5 सेकंड में पोल करते हैं और solution लौटाते हैं। in.php या createTask फॉर्मेट के लिए लिखी लाइब्रेरी भी काम करती हैं: उनका host unlock-api.com पर सेट करें।

import time, requests

class UnlockAPI:
    def __init__(self, key, base="https://unlock-api.com"):
        self.key, self.base = key, base

    def _post(self, method, **body):
        r = requests.post(f"{self.base}/{method}", json={"clientKey": self.key, **body}, timeout=30).json()
        if r.get("errorId"):
            raise RuntimeError(r.get("errorCode"))  # failed tasks are refunded
        return r

    def balance(self):
        return self._post("getBalance")["balance"]

    def solve(self, task, timeout=300):
        task_id = self._post("createTask", task=task)["taskId"]
        end = time.time() + timeout
        while time.time() < end:
            time.sleep(5)
            r = self._post("getTaskResult", taskId=task_id)
            if r["status"] == "ready":
                return r["solution"]
        raise TimeoutError(task_id)

इस्तेमाल

api = UnlockAPI("YOUR_API_KEY")
sol = api.solve({"type": "TurnstileTaskProxyless", "websiteURL": "https://example.com", "websiteKey": "0x4AAAA..."})
print(sol["token"])

पहले से मौजूद लाइब्रेरी का इस्तेमाल

ज़्यादातर सॉल्वर लाइब्रेरी में सर्वर एड्रेस बदला जा सकता है। इसे unlock-api.com (या फॉर्म API के लिए https://unlock-api.com/in.php) पर सेट करें और अपनी UNLOCK API key इस्तेमाल करें। टास्क नाम और जवाब वही रहते हैं।