Node.js Examples
Ready-to-use Node.js code for integrating CaptchaKings API.
📦 Requirements: Node.js 12+ and
axios, form-data packages
Installation
bash
npm install axios form-data
Basic Example
javascript
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
async function solveCaptcha(apiKey, imagePath) {
const url = 'https://captchakings.com/api/process.php';
const formData = new FormData();
formData.append('captcha', fs.createReadStream(imagePath));
try {
const response = await axios.post(url, formData, {
headers: {
...formData.getHeaders(),
'Authorization': `Bearer ${apiKey}`
}
});
return response.data;
} catch (error) {
return {
success: false,
error: error.message
};
}
}
// Usage
(async () => {
const API_KEY = 'ck_your_api_key_here';
const IMAGE_PATH = '/path/to/captcha.jpg';
const result = await solveCaptcha(API_KEY, IMAGE_PATH);
if (result.success) {
console.log(`✅ CAPTCHA Solved: ${result.data.prediction}`);
console.log(`Confidence: ${result.data.confidence}`);
console.log(`Credits Remaining: ${result.credits.credits_remaining}`);
} else {
console.log(`❌ Error: ${result.error}`);
}
})();
Download complete example: example.js