Was this helpful?
How to bypass MTCaptcha on TraceParts
Technical engineer
TraceParts (traceparts.com) is a digital engineering platform where manufacturers publish free 3D models, CAD files and 2D drawings for their industrial components, used by several million registered engineers and designers. To protect its sign-up form from automation and bots, the site uses the MTCaptcha system.
This captcha is an interactive widget that evaluates user behavior. For a successful solution via API v2, you need to extract the public site key (sitekey) and pass it along with the full page URL. In this guide, we will break down how to find these parameters, send the task, and correctly inject the received token.
To send a task via the modern API v2, the createTask endpoint is used. The task object must contain the following parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| type | String | Yes | Task type: MtCaptchaTaskProxyless or MtCaptchaTask |
| websiteURL | String | Yes | Full URL of the page where the captcha is located |
| websiteKey | String | Yes | MTCaptcha public site key (starts with MTPublic-) |
Parameters for MTCaptcha are static for a specific page and can be easily extracted from the source code.
- Open the website https://www.traceparts.com/ru/sign-up in your browser.
- Press F12 to open Developer Tools (DevTools) and go to the Elements tab.
- Press Ctrl+F (or Cmd+F) and search for mtcaptchaConfig.
- Unlike many MTCaptcha installations, the key here is not in a data-sitekey attribute — it is set in an inline script block, before the MTCaptcha client library loads:
html
<script type="text/javascript">
var mtcaptchaConfig = {
"sitekey": "MTPublic-Ia4y1KBYt",
"lang": "ru",
"widgetSize": "mini"
};
</script>
- The value of sitekey (in this example, MTPublic-Ia4y1KBYt) is your websiteKey.
- Copy the full URL from the browser's address bar. This will be your websiteURL.
Example of sending a task and polling for the result using the requests library via API v2 endpoints.
python
import requests
import time
API_KEY = 'YOUR_API_KEY'
WEBSITE_URL = 'https://www.traceparts.com/ru/sign-up'
WEBSITE_KEY = 'MTPublic-Ia4y1KBYt'
# 1. Create task via API v2
url = 'https://api.2captcha.com/createTask'
headers = {
'Content-Type': 'application/json'
}
payload = {
"clientKey": API_KEY,
"task": {
"type": "MtCaptchaTaskProxyless",
"websiteURL": WEBSITE_URL,
"websiteKey": WEBSITE_KEY
}
}
response = requests.post(url, headers=headers, json=payload)
result = response.json()
if result.get('errorId') == 0:
task_id = result.get('taskId')
print(f"Task created, ID: {task_id}")
# 2. Get result via API v2
res_url = 'https://api.2captcha.com/getTaskResult'
while True:
time.sleep(5) # Pause between requests
res_payload = {
"clientKey": API_KEY,
"taskId": task_id
}
res_response = requests.post(res_url, headers=headers, json=res_payload).json()
if res_response.get('errorId') == 0 and res_response.get('status') == 'ready':
print("Captcha solved successfully!")
token = res_response['solution']['token']
print(f"Token: {token}")
break
elif res_response.get('errorId') != 0:
print(f"Error: {res_response.get('errorDescription')}")
break
else:
continue
else:
print(f"Task creation error: {result.get('errorDescription')}")
Example of automation that dynamically extracts the sitekey from the page, sends the task via API v2, and injects the token.
python
from playwright.sync_api import sync_playwright
import requests
import time
API_KEY = 'YOUR_API_KEY'
TARGET_URL = 'https://www.traceparts.com/ru/sign-up'
def solve_mtcaptcha():
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
try:
page.goto(TARGET_URL)
# Wait for the MTCaptcha widget to appear
page.wait_for_selector('.mtcaptcha', timeout=10000)
# Extract sitekey from the page's mtcaptchaConfig object
site_key = page.evaluate("() => window.mtcaptchaConfig ? window.mtcaptchaConfig.sitekey : null")
if not site_key:
raise Exception("Failed to find MTCaptcha sitekey on the page.")
print(f"Found sitekey: {site_key}")
# Send to API v2
api_url = 'https://api.2captcha.com/createTask'
headers = {'Content-Type': 'application/json'}
payload = {
"clientKey": API_KEY,
"task": {
"type": "MtCaptchaTaskProxyless",
"websiteURL": page.url,
"websiteKey": site_key
}
}
task_response = requests.post(api_url, headers=headers, json=payload).json()
if task_response.get('errorId') != 0:
raise Exception(f"Task creation error: {task_response.get('errorDescription')}")
task_id = task_response.get('taskId')
# Waiting for the solution via getTaskResult
res_url = 'https://api.2captcha.com/getTaskResult'
token = None
for _ in range(20):
time.sleep(5)
res = requests.post(res_url, headers=headers, json={"clientKey": API_KEY, "taskId": task_id}).json()
if res.get('status') == 'ready':
token = res['solution']['token']
break
if res.get('errorId') != 0:
print(f"API error: {res.get('errorDescription')}")
break
if token:
print(f"Token received: {token}")
# Injecting the token into the form
# The token goes into the hidden mtcaptcha-verifiedtoken field;
# the page also keeps a separate captchaToken field next to the submit button
page.evaluate(f"""
let input = document.querySelector('#mtcaptcha-verifiedtoken-1');
if (input) {{
input.value = "{token}";
}}
let hiddenToken = document.querySelector('#captchaToken');
if (hiddenToken) {{
hiddenToken.value = "{token}";
}}
if (typeof window._mtcaptchaOnVerified === 'function') {{
window._mtcaptchaOnVerified("{token}");
}}
""")
print("Token injected into DOM.")
else:
print("Failed to get token.")
except Exception as e:
print(f"Error: {e}")
finally:
browser.close()
if __name__ == '__main__':
solve_mtcaptcha()
In some cases, if the standard MTCaptcha method encounters difficulties or specific protections, you can try an alternative solution using our Normal Captcha method.
If the MTCaptcha widget displays a classic text or character image to be typed, you can take a screenshot of this element using Playwright or Selenium and send it for recognition as a normal captcha. After receiving the text response, you can type it into the captcha input field using keyboard emulation.
Normal Captcha method documentation: https://2captcha.com/api-docs/normal-captcha
| Error / Problem | Cause | Solution |
|---|---|---|
| ERROR_WRONG_USER_KEY | Invalid or empty API key. | Check that the key is copied correctly from the dashboard. |
| ERROR_ZERO_BALANCE | Insufficient funds in the account. | Top up your account balance. |
| ERROR_CAPTCHA_UNSOLVABLE | The captcha cannot be solved (e.g., expired or incorrect parameters). | Ensure that the websiteKey and websiteURL are copied exactly. Do not use outdated values. |
| Token not accepted by the form | Incorrect field name for injection or missing callback trigger. | Check the page source code. Make sure you are injecting the token into the mtcaptcha-verifiedtoken field (and mirroring it into captchaToken) and triggering the verification function if necessary. |
- API testing sandbox: https://2captcha.com/setting#sandbox
- MTCaptcha API documentation: https://2captcha.com/api-docs/mtcaptcha
- Normal Captcha API documentation (alternative method): https://2captcha.com/api-docs/normal-captcha
- Python SDK on GitHub: https://github.com/2captcha/2captcha-python
- Other examples of bypassing captchas on websites: https://2captcha.com/h?category=sites