A package to use DeathByCaptcha API Client Fast and Easy.
npm install @sanjarani/dbc
npm install @sanjarani/dbc
`
Usage:
Just call HttpClient or SocketClient class based on your prefer connection and call methods:
`javascript
const dbc = require('@sanjarani/dbc');
const args = process.argv;
const username = "your-username"; // DBC account username
const password = "your-password"; // DBC account password
const clienttype = args[4];
let client;
if (clienttype === "HTTP"){
console.log("Using http client");
client = new dbc.HttpClient(username, password);
}
else {
console.log("using sockets client")
client = new dbc.SocketClient(username, password);
}
// Get user balance
client.get_balance((balance) => {
console.log(balance);
});
`
Available methods:
There are two types of Death by Captcha (DBC hereinafter) API:
_HTTP_ and _Socket_ ones.
Both offer the same functionalily, with the _socket API_
sporting faster responses and using way less connections.
To access the Socket API, use SocketClient class; for the HTTP API, use
HttpClient class.
$3
get_user
`javascript
get_user((user) => {})
`
Returns your DBC account details as a JSON with the following keys :
`
{
"user": {},
// your account numeric ID; if login fails, it will be the only item with the value of 0;
"rate": {},
// your CAPTCHA rate, i.e. how much you will be charged for one solved CAPTCHA in US cents;
"balance": {},
// your DBC account balance in US cents;
"is_banned": {}
// flag indicating whether your account is suspended or not.
}
`
get_balance
`javascript
get_balance((balance) => {})
`
Returns your DBC account balance in US cents (null for invalid user).
`
// example :
224.1401
`
get_captcha
`javascript
get_captcha(cid, (captcha) => {})
//The only argument cid is the CAPTCHA numeric ID.
`
Returns an uploaded CAPTCHA details as a JSON with the following keys:
`
{
"captcha": {},
// the CAPTCHA numeric ID; if no such CAPTCHAs found, it will be the only item with the value of 0;
"text": {},
// the CAPTCHA text, if solved, otherwise None;
"is_correct": {}
// flag indicating whether the CAPTCHA was solved correctly (DBC can detect that in rare cases).
}
`
get_text
`javascript
get_text(cid, (text) => {})
// The only argument cid is the CAPTCHA numeric ID.
`
Returns an uploaded CAPTCHA text (null if not solved).
report
`javascript
report(cid, (success) => {})
// The only argument cid is the CAPTCHA numeric ID.
`
Reports an _incorrectly_ solved CAPTCHA.
Returns true on success, false otherwise.
upload
`javascript
upload({ captcha = null, extra = {} }, (captcha) => {})
// The only argument captcha is the CAPTCHA image file name.
`
Uploads a CAPTCHA.
On successul upload you'll get the CAPTCHA details JSON
see get_captcha() method.
>NOTE: AT THIS POINT THE UPLOADED CAPTCHA IS NOT SOLVED YET!
> You have to poll for its status periodically using get_captcha() or get_text() method until the CAPTCHA is solved and you get the text.
decode
`javascript
decode({ captcha = null, timeout = null, extra = {} }, (captcha) => {})
`
A convenient method that uploads a CAPTCHA and polls for its status
periodically, but no longer than timeout (defaults to 60 seconds).
If solved, you'll get the CAPTCHA details JSON (see get_captcha() method for details). See upload() method for details on captcha
argument.
$3
Select HttpClient or SocketClient first, and then call decode method using image path and timeout:
`javascript
const dbc = require('@sanjarani/dbc');
const username = "your-username"; // DBC account username
const password = "your-password"; // DBC account password
let client;
let img = '../images/normal.jpg';
client = new dbc.SocketClient(username, password);
// decode a captcha
client.decode({
captcha: img,
timeout: 30
}, (response) => {
console.log(response);
});
`
The response object will return this result :
`json
{
captcha: 1633458547, //"captcha id"
text: "captcha text",
is_correct: true,
status: 0
}
``