Captcha
Captcha token verification and widget issuance.
Overview
Base path:
/v1/captchaPython namespace:
infra.captchatext
# Python
from infrai import infra
# TypeScript
import { InfraiClient } from "@infrai/sdk";
const client = new InfraiClient({ apiKey: process.env.INFRAI_API_KEY! });
// → client.captchaMethods
captcha.verify
POST /v1/captcha/verify
Verify a captcha token from the browser.
Python
python
infra.captcha.verify(token=..., vendor=None, remote_ip=None, min_score=None)TypeScript
typescript
client.captcha.verify(opts: CaptchaVerifyOptions): Promise<CaptchaVerifyResult>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
token | string | Required | Token returned by the captcha widget. |
vendor | "hcaptcha" | "recaptcha" | "turnstile" | "infrai" | Optional | Pin a specific vendor instead of auto-routing. |
remote_ip | string | Optional | Client IP for risk scoring. |
min_score | number | Optional | Minimum acceptable score (score-based vendors). |
Returns
CaptchaVerifyResult { valid, score?, vendor, hostname?, action? }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
res = infra.captcha.verify(token=user_submitted_token, remote_ip="203.0.113.7")
print("valid:", res.get("valid"), "| score:", res.get("score"))captcha.widget.create
POST /v1/captcha/widgets
Issue a captcha widget snippet and script URL.
Python
python
infra.captcha.widget.create(vendor=None, site_key_id=None)TypeScript
typescript
client.captcha.widget(opts): Promise<{ html, script_url }>Parameters
| Name | Type | Required | Description |
|---|---|---|---|
vendor | string | Optional | Pin a specific vendor instead of auto-routing. |
site_key_id | string | Optional | Configured site-key id. |
Returns
{ html, script_url }Example
一次性前置(每个范例都假定已完成):
bash
pip install infrai
# one-time auth (no secret needed): anonymous account + trial, writes ~/.infrai/credentials
python -c "from infrai import infra; infra.activate()"
# returning user instead: export INFRAI_API_KEY=ifr_pk_proj_...python
from infrai import infra
w = infra.captcha.widget.create(vendor="turnstile")
print("embed script:", w.get("script_url"))