Skip to content

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.

  1. Create an account

    Sign up and log in at yescaptcha.com.

  2. 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.

  3. Top up

    Your balance must be above 10 points to create tasks. Payment methods and VIP bonuses: Top-up and VIP.

  4. Check that the clientKey works

    getBalance returns 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; balance is your remaining points. ERROR_KEY_DOES_NOT_EXIST means the key was copied incorrectly.

  5. 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_key
    quickstart.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.png
    set -euo pipefail
    IMAGE="${1:-captcha.png}"
    BODY=$(base64 < "$IMAGE" | tr -d '\n') # no "data:" prefix, no line breaks
    curl -s https://api.yescaptcha.com/createTask \
    -H 'Content-Type: application/json' \
    -d "{\"clientKey\": \"${YESCAPTCHA_CLIENT_KEY}\", \"task\": {\"type\": \"ImageToTextTaskOcrBase\", \"body\": \"${BODY}\"}}"
    echo

    Run bash quickstart.sh captcha.jpg, python quickstart.py captcha.jpg or node quickstart.mjs captcha.jpg. Python needs pip install requests; Node.js needs version 18 or later.

  6. Read the result

    On success you get:

    {
    "errorId": 0,
    "status": "ready",
    "solution": { "text": "LMResm" },
    "taskId": "2376919c-1863-11ec-a012-94e6f7355a0b"
    }

    errorId 0 means success, and the text is in solution.text. If errorId is 1, look up errorCode in Error codes.