Quickstart
This page sends a first request with the simplest task type, ImageToTextTaskOcrBase, which reads the letters and digits in an image. It is synchronous (a single createTask request returns the result), costs 2 points (¥0.002) per image and needs no third-party site, so it is a good way to check that your account and code work.
-
Create an account
Sign up and log in at yescaptcha.com.
-
Copy your clientKey
On the dashboard (yescaptcha.com/dashboard.html), find “Your ClientKey” and click copy. Copy the whole value. Every API request is authenticated with it, so keep it private; if it leaks, reset it in the same place.
-
Top up
Your balance must be above 10 points to create tasks. Payment methods and VIP bonuses: Top-up and VIP.
-
Check that the clientKey works
getBalancereturns your balance and is free:终端窗口 curl -s https://api.yescaptcha.com/getBalance \-H 'Content-Type: application/json' \-d '{"clientKey": "YOUR_CLIENT_KEY"}'If you get
{"errorId": 0, "balance": 12345, ...}, you are ready;balanceis your remaining points.ERROR_KEY_DOES_NOT_EXISTmeans the key was copied incorrectly. -
Read an image
Download the sample image captcha.jpg (or use your own captcha image), put your client key in an environment variable and run one of the scripts:
终端窗口 export YESCAPTCHA_CLIENT_KEY=your_client_keyquickstart.sh #!/usr/bin/env bash# First request: read an alphanumeric image captcha with ImageToTextTaskOcrBase (synchronous, 2 points per image)# Usage: YESCAPTCHA_CLIENT_KEY=your_client_key bash quickstart.sh captcha.pngset -euo pipefailIMAGE="${1:-captcha.png}"BODY=$(base64 < "$IMAGE" | tr -d '\n') # no "data:" prefix, no line breakscurl -s https://api.yescaptcha.com/createTask \-H 'Content-Type: application/json' \-d "{\"clientKey\": \"${YESCAPTCHA_CLIENT_KEY}\", \"task\": {\"type\": \"ImageToTextTaskOcrBase\", \"body\": \"${BODY}\"}}"echoquickstart.py """First request: read an alphanumeric image captcha with ImageToTextTaskOcrBase(synchronous, 2 points per image).Usage:export YESCAPTCHA_CLIENT_KEY=your_client_keypython quickstart.py captcha.png"""import base64import osimport sysimport requestsCLIENT_KEY = os.environ["YESCAPTCHA_CLIENT_KEY"]image_path = sys.argv[1] if len(sys.argv) > 1 else "captcha.png"with open(image_path, "rb") as f:body = base64.b64encode(f.read()).decode() # no "data:" prefixr = requests.post("https://api.yescaptcha.com/createTask",json={"clientKey": CLIENT_KEY,"task": {"type": "ImageToTextTaskOcrBase", "body": body},},timeout=30,)data = r.json()if data.get("errorId"):raise SystemExit(f"{data.get('errorCode')}: {data.get('errorDescription')}")print("text:", data["solution"]["text"])quickstart.mjs // First request: read an alphanumeric image captcha with ImageToTextTaskOcrBase (synchronous, 2 points per image).// Usage: YESCAPTCHA_CLIENT_KEY=your_client_key node quickstart.mjs captcha.pngimport { readFileSync } from 'node:fs';const CLIENT_KEY = process.env.YESCAPTCHA_CLIENT_KEY;const body = readFileSync(process.argv[2] ?? 'captcha.png').toString('base64'); // no "data:" prefixconst res = await fetch('https://api.yescaptcha.com/createTask', {method: 'POST',headers: { 'Content-Type': 'application/json' },body: JSON.stringify({ clientKey: CLIENT_KEY, task: { type: 'ImageToTextTaskOcrBase', body } }),});const data = await res.json();if (data.errorId) throw new Error(`${data.errorCode}: ${data.errorDescription}`);console.log('text:', data.solution.text);Run
bash quickstart.sh captcha.jpg,python quickstart.py captcha.jpgornode quickstart.mjs captcha.jpg. Python needspip install requests; Node.js needs version 18 or later. -
Read the result
On success you get:
{"errorId": 0,"status": "ready","solution": { "text": "LMResm" },"taskId": "2376919c-1863-11ec-a012-94e6f7355a0b"}errorId0 means success, and the text is insolution.text. IferrorIdis 1, look uperrorCodein Error codes.
Next steps
Section titled “Next steps”- Token tasks such as reCAPTCHA and hCaptcha are asynchronous:
createTaskreturns ataskId, then you callgetTaskResultevery 5 seconds. The full flow is in Requests and responses; an example is reCAPTCHA v2. - Choose a task type: Task types and pricing.
- A client you can copy into your project: Python, Node.js.
- No code: Browser extension.