MTCaptcha Task
MTCaptcha: Solving MTCaptcha
This task type is used to solve MTCaptcha challenges. The solution provides a validation token.
1. Create Task
Use the `createTask` method to initiate the solving process. You must provide the `websiteURL` and the MTCaptcha `websiteKey`.
Task Object Parameters
Property | Type | Required | Description |
---|---|---|---|
type | String | Yes | Must be `MtCaptchaTaskProxyless` |
websiteURL | String | Yes | The full URL of the page where the MTCaptcha is present. |
websiteKey | String | Yes | The `data-mkey` or public key for the MTCaptcha instance. |
Example Request
POST https://api.captchasonic.com/createTask
Host: api.captchasonic.com
Content-Type: application/json
{
"apiKey": "YOUR_API_KEY",
"task": {
"type": "MtCaptchaTaskProxyless",
"websiteURL": "https://www.mtcaptcha.com/demo-p",
"websiteKey": "MTPublic-tqNCRE0GS"
}
}
Example Response
A successful creation request returns a taskId
which you will use in the next step.
{
"errorId": 0,
"status": "idle",
"taskId": "89a24cc1-33ed-4b12-8c46-8132044f1234"
}
2. Get Result
After creating a task, use the `getTaskResult` method to check the status and retrieve the solution. Poll this endpoint every 3-5 seconds until the status is `completed`.
Example Request
POST https://api.captchasonic.com/getTaskResult
Host: api.captchasonic.com
Content-Type: application/json
{
"apiKey": "YOUR_API_KEY",
"taskId": "89a24cc1-33ed-4b12-8c46-8132044f1234"
}
Example Success Response
When the task status becomes completed
, the response will contain the solution object.
{
"errorId": 0,
"status": "completed",
"solution": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ[...]dQ",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
},
"taskId": "89a24cc1-33ed-4b12-8c46-8132044f1234"
}
SDK Usage
# Coming soon: A simplified Python SDK
# pip install --upgrade captchasonic
#
# from captchasonic import CaptchaSonic
#
# client = CaptchaSonic(api_key="YOUR_API_KEY")
#
# solution = client.solve_mtcaptcha(
# website_url="https://www.mtcaptcha.com/demo-p",
# website_key="MTPublic-tqNCRE0GS"
# )
# print(f"MTCaptcha Token: {solution.token}")
Full Sample Code
import requests
import time
API_KEY = "YOUR_API_KEY"
API_URL = "https://api.captchasonic.com"
def solve_mtcaptcha():
# 1. Create the task
print("Creating MTCaptcha task...")
create_payload = {
"apiKey": API_KEY,
"task": {
"type": "MtCaptchaTaskProxyless",
"websiteURL": "https://www.mtcaptcha.com/demo-p",
"websiteKey": "MTPublic-tqNCRE0GS"
}
}
res = requests.post(f"{API_URL}/createTask", json=create_payload)
if res.status_code != 200:
print(f"Error creating task: {res.text}")
return
task_id = res.json().get("taskId")
if not task_id:
print(f"Could not find taskId in response: {res.json()}")
return
print(f"Task created successfully. Task ID: {task_id}")
# 2. Poll for the result
while True:
print("Polling for result...")
time.sleep(3) # Wait 3 seconds between polls
get_payload = {"apiKey": API_KEY, "taskId": task_id}
res = requests.post(f"{API_URL}/getTaskResult", json=get_payload)
if res.status_code != 200:
print(f"Error getting result: {res.text}")
continue
resp_json = res.json()
status = resp_json.get("status")
if status == "completed":
print("Task completed!")
return resp_json.get("solution")
elif status == "failed":
print(f"Task failed: {resp_json.get('errorDescription')}")
return
elif status == "processing":
print("Task is still processing, trying again...")
else:
print(f"Unknown status: {status}, response: {resp_json}")
# Run the solver
solution = solve_mtcaptcha()
if solution:
print("\n--- SOLUTION ---")
print(f"Token: {solution.get('token')}")
print("----------------")
// Full Node.js example
async function solveMtCaptcha() {
const API_KEY = "YOUR_API_KEY";
const API_URL = "https://api.captchasonic.com";
// 1. Create the task
console.log("Creating MTCaptcha task...");
const createRes = await fetch(`${API_URL}/createTask`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
apiKey: API_KEY,
task: {
type: "MtCaptchaTaskProxyless",
websiteURL: "https://www.mtcaptcha.com/demo-p",
websiteKey: "MTPublic-tqNCRE0GS"
}
})
});
const { taskId, errorId } = await createRes.json();
if (errorId !== 0 || !taskId) {
console.error("Error creating task:", await createRes.text());
return;
}
console.log(`Task created successfully. Task ID: ${taskId}`);
// 2. Poll for the result
while (true) {
console.log("Polling for result...");
await new Promise(resolve => setTimeout(resolve, 3000)); // Wait 3s
const getRes = await fetch(`${API_URL}/getTaskResult`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ apiKey: API_KEY, taskId })
});
const result = await getRes.json();
if (result.status === "completed") {
console.log("Task completed!");
return result.solution;
}
if (result.status === "failed") {
console.error(`Task failed: ${result.errorDescription}`);
return;
}
}
}
solveMtCaptcha().then(solution => {
if (solution) {
console.log("\n--- SOLUTION ---");
console.log(`Token: ${solution.token}`);
console.log("----------------");
}
});