Reference

Postman Collection for CaptchaAI API Testing

Testing the CaptchaAI API before writing code saves debugging time. This guide provides a ready-to-use Postman collection covering all core endpoints, with environment variables and test scripts.


Setting up the environment

Create a Postman environment with these variables:

Variable Value Description
base_url https://ocr.captchaai.com API base URL
api_key YOUR_API_KEY Your CaptchaAI API key
task_id (empty) Auto-populated after submit

Collection structure

1. Check balance

GET {{base_url}}/res.php

Query params:

{
  "key": "{{api_key}}",
  "action": "getbalance",
  "json": "1"
}

Test script:

const resp = pm.response.json();
pm.test("Balance check succeeds", () => {
  pm.expect(resp.status).to.eql(1);
  pm.expect(parseFloat(resp.request)).to.be.above(0);
});
console.log("Balance: $" + resp.request);

Expected response:

{
  "status": 1,
  "request": "5.42"
}

2. Submit reCAPTCHA v2

POST {{base_url}}/in.php

Body (form-data):

Key Value
key {{api_key}}
method userrecaptcha
googlekey 6Le-SITEKEY
pageurl https://example.com
json 1

Test script:

const resp = pm.response.json();
pm.test("Submit returns task ID", () => {
  pm.expect(resp.status).to.eql(1);
  pm.expect(resp.request).to.match(/^\d+$/);
});
pm.environment.set("task_id", resp.request);
console.log("Task ID: " + resp.request);

Expected response:

{
  "status": 1,
  "request": "71823456"
}

3. Submit Cloudflare Turnstile

POST {{base_url}}/in.php

Body (form-data):

Key Value
key {{api_key}}
method turnstile
sitekey 0x4AAAAAAAB...
pageurl https://example.com
json 1

4. Submit Image CAPTCHA

POST {{base_url}}/in.php

Body (form-data):

Key Value
key {{api_key}}
method base64
body (base64-encoded image string)
json 1

5. Poll result

GET {{base_url}}/res.php

Query params:

{
  "key": "{{api_key}}",
  "action": "get",
  "id": "{{task_id}}",
  "json": "1"
}

Test script:

const resp = pm.response.json();
if (resp.request === "CAPCHA_NOT_READY") {
  console.log("Not ready yet — wait 5s and retry");
} else if (resp.status === 1) {
  pm.test("CAPTCHA solved", () => {
    pm.expect(resp.request.length).to.be.above(10);
  });
  console.log("Token: " + resp.request.substring(0, 60) + "...");
} else {
  pm.test("No error", () => {
    pm.expect.fail("Error: " + resp.request);
  });
}

Expected responses:

{"status": 0, "request": "CAPCHA_NOT_READY"}
{"status": 1, "request": "03AGdBq26ZfPxL..."}

6. Report incorrect solve

GET {{base_url}}/res.php

Query params:

{
  "key": "{{api_key}}",
  "action": "reportbad",
  "id": "{{task_id}}",
  "json": "1"
}

Automating the submit → poll flow

Use Postman's Collection Runner with a pre-request script to add delay between poll attempts:

  1. Set the collection to run requests in order: Balance → Submit → Poll
  2. Add a 5-second delay in the Poll request's pre-request script:
// Pre-request script for Poll
const delay = 5000;
setTimeout(() => {}, delay);
  1. Use postman.setNextRequest("Poll result") in the Poll test script to loop until solved:
const resp = pm.response.json();
if (resp.request === "CAPCHA_NOT_READY") {
  postman.setNextRequest("Poll result"); // retry
} else {
  postman.setNextRequest(null); // stop
}

Error testing requests

Test error responses by sending invalid data:

Invalid API key

{
  "key": "INVALID_KEY",
  "method": "userrecaptcha",
  "googlekey": "6Le-SITEKEY",
  "pageurl": "https://example.com",
  "json": "1"
}

Expected: {"status": 0, "request": "ERROR_WRONG_USER_KEY"}

Zero balance

Expected: {"status": 0, "request": "ERROR_ZERO_BALANCE"}

Missing sitekey

Expected: {"status": 0, "request": "ERROR_WRONG_GOOGLEKEY"}


Importing as cURL

If you prefer cURL over Postman, equivalent commands:

Submit:

curl -X POST "https://ocr.captchaai.com/in.php" \
  -d "key=YOUR_API_KEY&method=userrecaptcha&googlekey=6Le-SITEKEY&pageurl=https://example.com&json=1"

Poll:

curl "https://ocr.captchaai.com/res.php?key=YOUR_API_KEY&action=get&id=71823456&json=1"

Balance:

curl "https://ocr.captchaai.com/res.php?key=YOUR_API_KEY&action=getbalance&json=1"

FAQ

Can I use Postman to test proxy-based solves?

Yes. Add proxy, proxytype, proxyport, proxylogin, and proxypassword fields to the submit request body.

How do I test callback URLs in Postman?

Use a webhook testing service (like webhook.site) as the pingback parameter. CaptchaAI sends the result to that URL when the solve completes.

Does the collection work with Postman's free tier?

Yes. All features used — environment variables, test scripts, and collection runner — are available in Postman's free plan.


Test the CaptchaAI API in Postman today

Get your API key at captchaai.com.


Discussions (0)

No comments yet.