PYTHON API
Full reference for all classes, configuration attributes, string-compatible return types, and functional helpers exported by doescap.
CLASS: DoesCap (alias: HCaptchaRelay)
Primary client managing relay server lifecycles, browser launching, and token capture. Supports context management (with DoesCap(...) as relay:)
and exports HCaptchaRelay = DoesCap plus relay.solve_relay = relay.solve for backward compatibility.
from doescap import DoesCap, RelayConfig
config = RelayConfig(host="0.0.0.0", port=8787, auto_open_browser=True)
with DoesCap(config=config) as relay:
# Active URLs (available after server starts inside solve)
print(relay.localhost_url, relay.relay_url)
# Synchronous solve (returns SolveResult | None)
token = relay.solve(
sitekey="4c672d35-0701-42b2-88c3-78380b0db560",
rqdata=None,
task_name="Account Verification",
timeout=180,
)
# Asynchronous solve (non-blocking executor wrapper)
# token = await relay.async_solve(sitekey="...", rqdata="...", quest_name="...")
if token:
# Update web UI & auto-close server after 25s
relay.mark_claimed(task_name="Account Verification", promo_code="PASS-200")
else:
# Mark error & auto-close server after 10s
relay.mark_failed("Timed out or invalid token")
solve(sitekey, rqdata=None, *, timeout=None, token=None, context_token=None, rqtoken=None, quest_name=None, task_name=None, captcha_host=None, custom_html=None, custom_html_path=None)→Optional[SolveResult]async_solve(...)→Optional[SolveResult](same parameters, runs insideloop.run_in_executor).solve_relay→ alias tosolve.mark_completed(message="Verification complete!")→ updatessuccess_messageshown on the web success screen.mark_claimed(quest_name="", reward_name="", promo_code="", task_name=None)→ updates UI with task name & copyable promo code, then callsclose()after 25s.mark_failed(error_msg)→ records error message in state and callsclose()after 10s.close()/cleanup()→ terminates headless browser subprocess/CDP socket and shuts down HTTP server.relay_url/localhost_url→ properties returninghttp://<lan_ip>:<active_port>/andhttp://127.0.0.1:<active_port>/.
CLASS: RelayConfig
Configuration class governing network bind, port selection, browser mode, custom webpages, and Windows firewall rules.
Every field can also be passed directly as a keyword argument to DoesCap(...):
| Option | Type | Default | Purpose |
|---|---|---|---|
host |
str | "0.0.0.0" |
Bind IP address. "0.0.0.0" allows local & LAN connectivity. |
port |
int | 8787 |
Preferred TCP port (auto-picks free ephemeral port if busy). |
auto_open_browser |
bool | True |
Launches default browser on desktop or via Android/Termux intents. |
browser_path |
str | None | None |
Binary path or keyword (e.g. "chrome", "brave") to enable CDP screencast mode. |
timeout |
int | 300 |
Maximum wait time in seconds before returning None. |
title |
str | "DoesCap Relay" |
Header and <title> text displayed in the web UI. |
theme |
str | "dark" |
Built-in solver UI & hCaptcha widget theme ("dark" or "light"). |
allow_firewall_rule |
bool | True |
On Windows, attempts netsh advfirewall inbound TCP rule for the active port. |
custom_html |
str | None | None |
Raw custom HTML template string served at /. |
custom_html_path |
str | None | None |
Filepath to a custom .html file served at /. |
custom_assets_dir |
str | None | None |
Directory for static files served safely under /assets/*. |
captcha_host |
str | None | None |
Optional hCaptcha origin hostname override (e.g. "discord.com") for origin-locked Enterprise challenges. |
CLASS: SolveResult (STR SUBCLASS)
SolveResult subclasses Python's built-in str. On success, solve() returns a SolveResult
that behaves as a normal string while exposing telemetry attributes; on timeout or error, solve() returns None.
result = relay.solve(sitekey="...")
if result:
# Direct string usage (zero casting needed)
headers = {"X-Captcha-Key": result}
# Access result telemetry
print("Success:", result.success) # True
print("Token:", result.token) # Same as str(result)
print("Elapsed:", result.elapsed_seconds) # float seconds
print("Metadata:", result.metadata) # {"mode": "direct", "port": 8787}
FUNCTIONAL & NETWORK HELPERS
Top-level exports in doescap for single-call usage and LAN IP discovery:
from doescap import solve_captcha, async_solve_captcha, get_local_ip, __version__
print("DoesCap version:", __version__)
# 1. Discover LAN IPv4 address (returns "127.0.0.1" if offline)
ip = get_local_ip()
# 2. One-shot sync helper (opens & closes DoesCap automatically, returns Optional[str])
token = solve_captcha(
sitekey="...",
rqdata=None,
port=8787,
host="0.0.0.0",
auto_open_browser=True,
browser_path=None,
timeout=300,
title="DoesCap Relay",
captcha_host=None,
custom_html=None,
custom_html_path=None,
custom_assets_dir=None,
)
# 3. One-shot async helper (runs solve_captcha in asyncio executor)
token = await async_solve_captcha(sitekey="...", port=8787)