Full working example for solving reCAPTCHA v2 Enterprise using the CaptchaAI API.
Languages: Python, Node.js, PHP, Go, Java, C#, Ruby, Rust, Kotlin, Bash
This example accompanies the blog article: How to Solve reCAPTCHA v2 Enterprise Using API
- A CaptchaAI account with API key (get one here)
- A target page with reCAPTCHA v2 Enterprise for testing
- One or more of: Python 3.8+, Node.js 16+, PHP 8.0+, Go 1.21+, Java 11+, .NET 8+, Ruby 3.0+, Rust 1.70+, Kotlin 1.9+, or Bash with curl and jq
-
Clone the repository:
git clone https://github.com/CaptchaAI/CaptchaAI-Examples.git cd CaptchaAI-Examples/articles/how-to-solve-recaptcha-v2-enterprise-using-api -
Copy the environment file and add your credentials:
cp .env.example .env
-
Edit
.envwith your API key and target page details. If the target page includes adata-sattribute on the reCAPTCHA element, add that value toCAPTCHA_DATA_S. -
Follow the language-specific setup below.
cd python
pip install -r requirements.txt
python solve.pycd node
npm install
node solve.jscd php
composer install
php solve.phpcd go
go run solve.gocd java
javac Solve.java
java Solvecd csharp
dotnet runcd ruby
ruby solve.rbcd rust
cargo runcd kotlin
kotlinc solve.kt -include-runtime -d solve.jar
java -jar solve.jarcd bash
chmod +x solve.sh
bash solve.sh- Submit — sends the sitekey, page URL, and
enterprise=1flag (plus optionaldata-s) to the CaptchaAI API - Poll — checks for the solution every few seconds (15 s initial wait, then every 5 s)
- Receive — prints the
g-recaptcha-responsetoken for injection into the target form
| Variable | Required | Description |
|---|---|---|
CAPTCHAAI_API_KEY |
Yes | Your CaptchaAI API key |
CAPTCHA_SITEKEY |
Yes | The data-sitekey from the target page |
CAPTCHA_PAGEURL |
Yes | Full URL of the page with the CAPTCHA |
CAPTCHA_DATA_S |
No | The data-s value if present on the page |
POLL_INTERVAL |
No | Seconds between polls (default: 5) |
MAX_TIMEOUT |
No | Max seconds to wait (default: 120) |