thelastiq-recaptcha v1.2.1
thelast-iq-test-Recaptcha-npm-package
A simple and framework to generate and verify the last IQ test Recaptcha data. This package currently supports TheLastIqTest Recaptcha V1.
Installation
npm i thelast-iq-test
yarn add thelast-iq-test
Usage
getReCaptchaQuestion(questionType: string, wordLength: number, apiKey: string): Promise<any>
This function makes a GET request to retrieve a ReCaptcha question.
Parameters
- questionType:
string
(required): A string representing the type of ReCaptcha question to retrieve. - wordLength
number
(required): A number representing the number of characters in the ReCaptcha question. - apiKey
secret
(required): A string representing the API key to use for the request.
Returns
- A Promise that resolves to the data returned by the API.
- Get your ReCaptcha API Key here TheLastIqTest Recaptcha API KEY
answerReCaptchaQuestion(question: string, answer: string, apiKey: string): Promise<any>
This function makes a POST request to answer a ReCaptcha question.
Parameters
- question:
string
(required): A string representing the ReCaptcha question to answer. - answer
string
(required): A string representing the answer to the ReCaptcha question. - apiKey
secret
(required): A string representing the API key to use for the request.
Returns
- A Promise that resolves to the data returned by the API.
const { getReCaptchaQuestion, answerReCaptchaQuestion } = require('thelast-iq-test-recaptcha');
const apiKey = "Your_API_Key";
async function getQuestion(apiKey) {
const questionType = "CHARACTERS";
const wordLength = 4;
try {
const result = await getReCaptchaQuestion(questionType, wordLength, apiKey);
console.log(result);
} catch (error) {
console.error(error);
}
}
async function answerQuestion(apiKey) {
const question = "DCBAA";
const answer = "43211";
try {
const result = await answerReCaptchaQuestion(question, answer, apiKey);
console.log(result);
} catch (error) {
console.error(error);
}
}
getQuestion(apiKey);
answerQuestion(apiKey);
Error Handling
Both the getReCaptchaQuestion
and answerReCaptchaQuestion
functions have error handling built in to handle common errors that may occur during the requests. In case of an error, the functions will return an error object or throw an error.
If the getReCaptchaQuestion
function encounters an error, it will throw an error object with the error message. The error object will have the following properties:
message
: A string representing the error message.isAxiosError
: A boolean indicating whether the error was caused by an Axios request.response
: An object containing the Axios response data, including the status code and error message.
If the answerReCaptchaQuestion
function encounters an error, it will throw an error object with the error message. The error object will have the following properties:
message
: A string representing the error message.response
: An object containing the Axios response data, including the status code and error message.
Example Response
The response from the ReCaptcha API will vary depending on the type of question and answer provided. In general, the response will contain a status code and a message.
Here is an example response from the getReCaptchaQuestion
function:
{
"status": 200,
"instruction": 'IF A = 1, B = 2, C = 3, AND 1 = A, 2 = B, 3 = C. What is?',
"question": 'ACCE'
}
Here is an example response from the answerReCaptchaQuestion
function:
{
"status": 200,
"message": "GOD JOB"
}
Dependencies
The thelast-iq-test
package has one dependency: axios
. This package is used to make HTTP requests to the ReCaptcha API.
Contribution
If you would like to contribute to the thelast-iq-test
package, you can do so by submitting a pull request on GitHub. The package repository can be found at https://github.com/suleigolden/thelast-iq-test-npm-package
Credits
The thelast-iq-test
package was created by TheLastCodeBender and is maintained by TheLastIQGTest.
The package was inspired by the ReCaptcha API provided by Google, which is used by millions of websites to protect against spam and abuse.
We would like to thank the developers of the following open source packages, which were used in the creation of this package:
axios
: A promise-based HTTP client for the browser and Node.js.fetch
: A browser API for making HTTP requests.Jest
: A JavaScript testing framework used for unit testing.
We also want to thank the many contributors who have helped improve the package through bug reports, feature requests, and code contributions. Your contributions are greatly appreciated!
If you have any questions or feedback about the package, please don't hesitate to contact us. We would be happy to hear from you.
License
Copyright (c) 2023 TheLastIQtest