Self-developed CAPTCHA

Self-developed CAPTCHA (character image / arithmetic), rendered locally with Pillow and no third-party dependency; each answer is validated only once.

/api/captcha_self/

Service Description

The self-hosted CAPTCHA depends on no third-party service: the platform draws character images or arithmetic questions locally with Pillow, making it suitable when data must not leave your infrastructure or when you want a zero-cost in-house CAPTCHA.

Integration takes two steps: call the generate endpoint to get a captcha_id and a base64 image (with an expiry), then call the verify endpoint with the user's answer. Answers are one-time — they become invalid immediately after verification, whether it succeeds or fails, so a failed attempt requires a new CAPTCHA. The server stores only an HMAC-SHA256 digest of the answer, never the plaintext.

This channel is public and requires no project signature. The server applies per-IP rate limits (60 generates/min, 120 verifies/min) and disables caching on responses so images are not reused by browsers or proxies.

This service also provides Slider CAPTCHA and Chinese Character Picker channels: the former aligns a puzzle piece with the gap, the latter asks you to click 2-4 characters in order. Neither sends answer coordinates — they are kept server-side for verification.

Choosing a channel: character/arithmetic is the lightest option for form anti-bot; slider offers a drag experience; the Chinese character picker is the most intuitive for Chinese-speaking users.

Response Format

Every endpoint returns the same JSON envelope; the payload is always inside data:

{
  "code": 10000,
  "msg": "成功",
  "data": { ... }
}
  • code: business status code. 10000 means success; anything else is an error — see the Error Codes page for the full list.
  • msg: a human-readable message you can show to end users, but never use it for program logic.
  • data: the payload; usually null on error. Each endpoint's Response section lists its data fields.

Judge success by code, not by the HTTP status code. View all error codes

Self-developed CAPTCHA

SpiderServices/Captcha self-developed generation engine (drawn with Pillow) Available · No Signature

Two-step integration: call generate first to obtain a captcha_id and image (base64), then POST the user answer to verify. The answer is single-use: it expires immediately after validation, correct or not, so the frontend must fetch a new image afterwards.

GET /api/captcha_self/generate Total calls: 1

Generate CAPTCHA

Generate one CAPTCHA and return its captcha_id, base64 image and validity period.

Optional: char = character image (digits + uppercase letters); arithmetic = addition / subtraction

Optional: only applies when kind=char; valid range 4-6 (default 4)

  • Request method GET with parameters in the query string; public Endpoint, no project signature required.
  • captcha_id must be sent back to verify together with the answer; image can be used directly as an <img src>.
  • The response includes Cache-Control: no-store, so CAPTCHA images are not cached or reused by browsers or proxies.
  • Each IP can generate at most 60 CAPTCHAs per minute; exceeding this returns 20040.
Response Common envelope
Field Type Description
captcha_id string Captcha ID, pass it back when verifying
kind string Kind: char/arithmetic
image string base64 image (data URI)
expire_in int TTL (seconds)
Example response
{"captcha_id": "9f1c1f14-6b0a-4a3e-9c31-2c9b6f0d1a55", "kind": "char", "image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...", "expire_in": 300}
POST /api/captcha_self/verify Total calls: 0

Validate CAPTCHA

Submit the user answer for validation; the CAPTCHA is consumed on use (invalidated immediately after validation).

Required: the captcha_id (UUID) returned by the generate Endpoint

Required: the answer entered by the user (case-insensitive for characters; enter the computed result for arithmetic)

  • The request body is an application/x-www-form-urlencoded form; this is an open endpoint and needs no project signature.
  • Validation passed: code=10000 with data.passed=true;
  • Not passed (wrong answer / expired / already used / not found): code=20003 with data.passed=false; see msg for the cause;
  • A non-UUID captcha_id returns code=20002; a missing parameter returns code=20001.
  • The answer is single-use: repeated submissions of the same CAPTCHA can succeed only once, so call generate again after a failure.
  • Each IP can verify at most 120 times per minute; exceeding this returns 20040. Answers are compared in constant time and only a digest is stored.
Response Common envelope
Field Type Description
passed bool Whether the check passed
Example response
{"passed": true}
XiaoYingAPI · Unified API Aggregation Service