Requests and responses
Every method takes an HTTPS POST with a JSON body (only /useragent is GET), is authenticated with the clientKey in the body, and returns JSON: errorId 0 means success, 1 means failure with an errorCode. Solving a captcha takes two steps: createTask creates a task and getTaskResult is polled every 5 seconds for the result. Synchronous types return the result from createTask directly.
Request
Section titled “Request”curl -s https://api.yescaptcha.com/createTask \ -H 'Content-Type: application/json' \ -d '{"clientKey": "YOUR_CLIENT_KEY", "task": {"type": "ImageToTextTaskOcrBase", "body": "BASE64_IMAGE"}}'- Endpoint:
https://api.yescaptcha.com(global) orhttps://cn.yescaptcha.com(China). See Endpoints. - The body is JSON, sent with
Content-Type: application/json, under 6 MB. JSON cannot contain comments. - Every request includes
clientKey, copied in full from the dashboard. - With Python requests use
json=data, notdata=data(the latter sends a form and returnsERROR_TASK_ABSENTorERROR_REQUIRED_FIELDS).
Response
Section titled “Response”Success:
{ "errorId": 0, "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006" }Failure:
{ "errorId": 1, "errorCode": "ERROR_ZERO_BALANCE", "errorDescription": "帐户余额不足" }| Field | Description |
|---|---|
errorId |
0 success, 1 failure |
errorCode |
The error code on failure; meanings and fixes in Error codes |
errorDescription |
A text description of the failure (Chinese for most codes) |
taskId |
The task ID |
status |
processing or ready |
solution |
The result; its fields depend on the task type (see each task type page) |
Check errorId and errorCode in your code, not the wording of errorDescription, which may change.
Synchronous and asynchronous
Section titled “Synchronous and asynchronous”| Asynchronous | Synchronous | |
|---|---|---|
| Which types | Token types (reCAPTCHA, hCaptcha, Turnstile, FunCaptcha), the Cloudflare challenge page, ImageToTextTask, ImageToTextTaskM1 |
Image recognition (names ending in Classification), ImageToTextTaskOcrBase, ImageToTextTaskMuggle |
createTask returns |
taskId |
status: "ready" and solution |
| Getting the result | Call getTaskResult every 5 seconds |
Nothing more to do |
The “Mode” column in Task types and pricing shows which applies to each type.
Polling
Section titled “Polling”- After
createTaskreturns ataskId, wait 5 seconds and callgetTaskResult. - On
status: "processing", wait another 5 seconds and try again; onstatus: "ready", the result is insolution. - On
errorId: 1, stop polling this task and handle theerrorCode.
- Repeated queries for the same
taskIdwithin 5 seconds returnprocessingright away; polling faster does not get the result sooner. - A task runs for at most about 110 seconds (180 to 220 seconds for a few types); after that it returns
ERROR_TASK_TIMEOUTand the points are refunded. - Results are kept for about 10 minutes; after that the
taskIdexpires and queries returnERROR_TASKID_INVALID. - Queries are free; only creating a task is charged.
Message language
Section titled “Message language”For automatic pauses, cached invalid parameters and stop-polling hints, errorDescription follows the Accept-Language request header: Chinese if it starts with zh, English for any other language, and both if the header is absent. Other error descriptions are unaffected.
- createTask
- getTaskResult
- Rate limits: too many errors pause your key for a few minutes