A complete Node.js Express.js implementation of the Turnstile Solver API using Playwright for browser automation.
- Express.js Framework: Fast, unopinionated web framework for Node.js
- Playwright Integration: Cross-browser automation with Chromium, Firefox, and WebKit
- Multi-threading Support: Configurable browser pool for concurrent processing
- Proxy Support: Built-in proxy rotation capability
- Custom Logging: Colored console logging with timestamps
- Graceful Shutdown: Proper cleanup of browser instances
- REST API: Simple GET endpoints for solving and retrieving results
- Result Persistence: Automatic saving/loading of results to/from JSON file
-
Clone or download the project files
-
Install dependencies:
npm install
-
Install Playwright browsers:
npx playwright install
npm start
npm run dev
node server.js [options]
Options:
--headless <value> Run browser in headless mode (default: "true")
--useragent <value> Custom User-Agent string
--debug <value> Enable debug mode (default: "false")
--browser-type <value> Browser type: chromium, firefox, webkit (default: "chromium")
--thread <value> Number of browser threads (default: "1")
--proxy <value> Enable proxy support (default: "false")
--host <value> Server host (default: "127.0.0.1")
--port <value> Server port (default: "5000")
Basic server with debug mode:
node server.js --debug true --thread 3
Headless mode with custom user agent:
node server.js --headless true --useragent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
With proxy support and multiple threads:
node server.js --proxy true --thread 5 --browser-type firefox
GET /turnstile
Parameters:
url
(required): The URL where Turnstile is to be validatedsitekey
(required): The site key for Turnstileaction
(optional): Turnstile action parametercdata
(optional): Custom data parameter
Example:
GET /turnstile?url=https://example.com&sitekey=your-site-key
Response:
{
"task_id": "550e8400-e29b-41d4-a716-446655440000"
}
GET /result
Parameters:
id
(required): Task ID returned from/turnstile
endpoint
Example:
GET /result?id=550e8400-e29b-41d4-a716-446655440000
Success Response:
{
"value": "turnstile-response-token",
"elapsed_time": 2.531
}
Failure Response:
{
"value": "CAPTCHA_FAIL",
"elapsed_time": 10.0
}
GET /
Returns an HTML page with API documentation.
Create a proxies.txt
file in the project root with one proxy per line:
http://proxy1:port
http://username:password@proxy2:port
socks5://proxy3:port
https://user:pass@proxy4:port
Results are automatically saved to results.json
and persist between server restarts.
- Chromium (default): Most compatible, recommended
- Firefox: Good alternative with different fingerprint
- WebKit: Safari engine, lighter resource usage
The server includes comprehensive error handling:
- Invalid parameters return 400 status
- Failed captcha solving returns 422 status
- Server errors return 500 status
- Graceful shutdown on SIGINT/SIGTERM
Color-coded logging with timestamps:
- DEBUG (Magenta): Detailed operation info
- INFO (Blue): General information
- SUCCESS (Green): Successful operations
- WARNING (Yellow): Warning messages
- ERROR (Red): Error messages
- Multi-threading: Use
--thread
option to run multiple browsers concurrently - Headless Mode: Reduces resource usage but requires custom user agent
- Proxy Rotation: Helps avoid rate limiting when enabled
- Browser Pool: Browsers are reused to improve performance
- Framework: Uses Express.js instead of Quart
- Browser Automation: Uses Playwright Node.js instead of Python
- Async Handling: Uses Node.js async/await patterns
- Process Management: Uses Node.js process signals for cleanup
- Configuration: Uses Commander.js for CLI argument parsing
MIT License - see original project for attribution details.
This is a direct port of the Python version. Please refer to the original repository for contribution guidelines.