API Tutorials

Solve Grid Image CAPTCHA with Node.js and CaptchaAI

Grid image CAPTCHAs present a 3×3 or 4×4 grid with an instruction like "select all squares with traffic lights." This tutorial shows how to solve them from Node.js using CaptchaAI and Puppeteer.


Prerequisites

Item Value
CaptchaAI API key From captchaai.com
Node.js 14+
Libraries axios, puppeteer

Step 1: Capture the grid image

const puppeteer = require('puppeteer');
const fs = require('fs');

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com/page-with-recaptcha');

// Switch to the reCAPTCHA challenge iframe
const frames = page.frames();
const challengeFrame = frames.find((f) => f.url().includes('recaptcha/api2/bframe'));

// Get the instruction text
const instruction = await challengeFrame.$eval(
  '.rc-imageselect-desc-no-canonical',
  (el) => el.textContent.trim()
);

// Screenshot the grid
const grid = await challengeFrame.$('.rc-imageselect-target');
await grid.screenshot({ path: 'grid.png' });

Step 2: Submit to CaptchaAI

const axios = require('axios');
const FormData = require('form-data');

const API_KEY = 'YOUR_API_KEY';
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

const form = new FormData();
form.append('key', API_KEY);
form.append('method', 'post');
form.append('grid_size', '3x3');
form.append('img_type', 'recaptcha');
form.append('instructions', instruction);
form.append('json', '1');
form.append('file', fs.createReadStream('grid.png'));

const { data: submitData } = await axios.post('https://ocr.captchaai.com/in.php', form, {
  headers: form.getHeaders(),
});

if (submitData.status !== 1) throw new Error(submitData.request);
const taskId = submitData.request;
console.log(`Task submitted: ${taskId}`);

Step 3: Poll for the solution

await sleep(5000);

let cellsToClick;
for (let i = 0; i < 30; i++) {
  const { data: pollData } = await axios.get('https://ocr.captchaai.com/res.php', {
    params: { key: API_KEY, action: 'get', id: taskId, json: 1 },
  });

  if (pollData.status === 1) {
    cellsToClick = JSON.parse(pollData.request);
    console.log('Click cells:', cellsToClick);
    break;
  }
  if (pollData.request !== 'CAPCHA_NOT_READY') {
    throw new Error(pollData.request);
  }
  await sleep(5000);
}

Step 4: Click the correct tiles

const tiles = await challengeFrame.$$('.rc-imageselect-tile');

for (const cellNum of cellsToClick) {
  await tiles[cellNum - 1].click();
  await sleep(300);
}

// Click verify
await challengeFrame.click('#recaptcha-verify-button');
console.log(`Solved: clicked tiles ${JSON.stringify(cellsToClick)}`);
await browser.close();

Expected output:

Click cells: [1, 3, 6, 9]
Solved: clicked tiles [1,3,6,9]

FAQ

Does this work with 4×4 grids?

Yes. Set grid_size to 4x4 in the request parameters.

Can I use Playwright instead of Puppeteer?

Yes. The CaptchaAI API calls are the same — only the browser automation code changes.

What if the CAPTCHA refreshes with new images?

Some reCAPTCHA challenges load new tiles. You may need to capture and submit again for each round.



Start solving Grid Image CAPTCHAs with CaptchaAI →

Discussions (0)

No comments yet.

Related Posts

Troubleshooting Grid Image Coordinate Errors: Diagnosis and Fix
Fix grid image CAPTCHA coordinate errors when using Captcha AI.

Fix grid image CAPTCHA coordinate errors when using Captcha AI. Covers wrong grid size, cell numbering mismatc...

Automation Python Image OCR
Feb 26, 2026
Troubleshooting Common Grid Image CAPTCHA Errors and Fixes
Fix common grid image CAPTCHA solving errors.

Fix common grid image CAPTCHA solving errors. Covers image quality issues, wrong cell selection, timeout error...

Automation Image OCR Grid Image
Mar 29, 2026
Comparisons Grid Image vs Normal Image CAPTCHA: API Parameter Differences
Compare Grid Image and Normal Image CAPTCHA types — different API parameters, response formats, and when to use each method with Captcha AI.

Compare Grid Image and Normal Image CAPTCHA types — different API parameters, response formats, and when to us...

Automation Image OCR Migration
Mar 25, 2026
API Tutorials Solve Image CAPTCHA with Node.js and CaptchaAI
Step-by-step Node.js tutorial for solving distorted text image CAPTCHAs using the Captcha AI OCR API.

Step-by-step Node.js tutorial for solving distorted text image CAPTCHAs using the Captcha AI OCR API. Includes...

Automation Image OCR Node.js
Mar 21, 2026
Tutorials Node.js Worker Threads for Parallel CAPTCHA Solving
Use Node.js Worker Threads for true parallel CAPTCHA solving with Captcha AI.

Use Node.js Worker Threads for true parallel CAPTCHA solving with Captcha AI. Offload solving to separate thre...

Automation Image OCR DevOps
Mar 11, 2026
API Tutorials Solve Grid Image CAPTCHA with Python and CaptchaAI
Step-by-step Python tutorial for solving grid image CAPTCHAs ( re CAPTCHA image challenges) using the Captcha AI API.

Step-by-step Python tutorial for solving grid image CAPTCHAs ( re CAPTCHA image challenges) using the Captcha...

Automation Python Image OCR
Feb 24, 2026
Explainers How Grid Image CAPTCHA Challenges Work
Understand how grid image CAPTCHAs work.

Understand how grid image CAPTCHAs work. Learn about grid formats, detection methods, and how to solve them wi...

Automation Image OCR Grid Image
Jan 11, 2026
Explainers How Grid Image CAPTCHAs Work
Understand how grid image CAPTCHAs work — the tile-based image challenges used by re CAPTCHA and other providers.

Understand how grid image CAPTCHAs work — the tile-based image challenges used by re CAPTCHA and other provide...

Automation Image OCR Grid Image
Feb 27, 2026
API Tutorials How to Solve Grid Image CAPTCHA Automatically
Step-by-step guide to solving grid image CAPTCHAs with Captcha AI API.

Step-by-step guide to solving grid image CAPTCHAs with Captcha AI API. Includes image capture, API submission,...

Automation Image OCR Grid Image
Feb 08, 2026
Troubleshooting Common OCR CAPTCHA Errors and Fixes
Fix common image/OCR CAPTCHA solving errors.

Fix common image/OCR CAPTCHA solving errors. Covers wrong text, image quality issues, format errors, and tips...

Automation Image OCR
Feb 28, 2026
API Tutorials How to Solve reCAPTCHA v2 Callback Using API
how to solve re CAPTCHA v 2 callback implementations using Captcha AI API.

Learn how to solve re CAPTCHA v 2 callback implementations using Captcha AI API. Detect the callback function,...

Automation reCAPTCHA v2 Webhooks
Mar 01, 2026
API Tutorials Solve GeeTest v3 CAPTCHA with Python and CaptchaAI
Step-by-step Python tutorial for solving Gee Test v 3 slide puzzle CAPTCHAs using the Captcha AI API.

Step-by-step Python tutorial for solving Gee Test v 3 slide puzzle CAPTCHAs using the Captcha AI API. Includes...

Automation Python Testing
Mar 23, 2026
API Tutorials Case-Sensitive CAPTCHA API Parameter Guide
How to use the regsense parameter for case-sensitive CAPTCHA solving with Captcha AI.

How to use the regsense parameter for case-sensitive CAPTCHA solving with Captcha AI. Covers when to use, comm...

Python Web Scraping Image OCR
Apr 09, 2026