> For the complete documentation index, see [llms.txt](https://docs.hmcaptcha.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hmcaptcha.com/recognition-api/tiktok-captcha.md).

# Tiktok Captcha

## Create task

<mark style="color:green;">`POST`</mark> `https://hmcaptcha.com/Recognition?wait=1`

**1.SLIDE CAPTCHA**

<img src="/files/n6G3PK74n2h1eLZ9wloI" alt="" data-size="original">

**Example** `https://hmcaptcha.com/Recognition?wait=1`

`{`\
&#x20;    `"Apikey": "YOUR APIKEY",`\
&#x20;    `"Type": "ALL_CAPTCHA_SLIDE",`\
&#x20;    `"Image": "Image as base64 encoded"`\
`}`

**2.SELECT 2 OBJECT**

<div align="left"><figure><img src="/files/z7rjf5taQNiNtLxVVjsy" alt="" width="375"><figcaption></figcaption></figure></div>

**Example** `https://hmcaptcha.com/Recognition?wait=1`

`{`\
&#x20;    `"Apikey": "YOUR APIKEY",`\
&#x20;    `"Type": "TIKTOK_OBJ",`\
&#x20;    `"Image": "Image as base64 encoded",`\
&#x20;    `"URL_Image": "Required if Image is missing."`\
`}`

`` Note: chỉ cần 1 trong 2 tham số `Image` hoặc `URL_Image` ``

**3.ROTATE CAPTCHA APP**

<div align="left"><figure><img src="/files/gLMcH2Fz2JwFXxervBXT" alt="" width="294"><figcaption></figcaption></figure></div>

**Example** `https://hmcaptcha.com/Recognition?wait=1`

`{`\
&#x20;    `"Apikey": "YOUR APIKEY",`\
&#x20;    `"Type": "TIKTOK_ROTATE_APP",`\
&#x20;    `"Image": "Image as base64 encoded"`\
`}`

`Note: Image gửi lên là ảnh chụp màn hình hoặc ảnh chỉ lấy phần captcha`

**4.ROTATE CAPTCHA WEB**

<img src="/files/JXS0AgwufK4XzxMXHJhs" alt="" data-size="original">

**Example** `https://hmcaptcha.com/Recognition?wait=1`

`{`\
&#x20;    `"Apikey": "YOUR APIKEY",`\
&#x20;    `"Type": "TIKTOK_ROTATE_WEB",`\
&#x20;    `"URL_Image1": "url image 1 of captcha (ảnh bên trong)",`\
&#x20;    `"URL_Image2": "url image 2 of captcha (ảnh bên ngoài)"`\
`}`

#### Query Parameters

| Name | Type | Description                                                                                                                                       |
| ---- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| wait | Bool | If the 'wait=1' parameter is added to the URL, the result will return immediately after the captcha is solved without needing to call 'getResult' |

#### Headers

| Name                                           | Type   | Description      |
| ---------------------------------------------- | ------ | ---------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/json |

#### Request Body

<table data-full-width="false"><thead><tr><th width="163">Name</th><th width="87">Type</th><th>Description</th></tr></thead><tbody><tr><td>Apikey<mark style="color:red;">*</mark></td><td>String</td><td>The apikey or subscription key</td></tr><tr><td>Type<mark style="color:red;">*</mark></td><td>String</td><td><p><code>ALL_CAPTCHA_SLIDE</code><br><code>TIKTOK_OBJ</code><br><code>TIKTOK_ROTATE_APP</code></p><p><code>TIKTOK_ROTATE_WEB</code></p></td></tr><tr><td>Image</td><td>String</td><td>Image encoded as base64</td></tr><tr><td>URL_Image</td><td>String</td><td>Required if <code>Image</code> is missing. </td></tr><tr><td>Question</td><td>String</td><td><p>Questions in English,<br>Not required,</p><p>default: "<code>Select 2 objects that are the same shape</code>"</p></td></tr><tr><td>ref</td><td>String</td><td>Add to get referral money</td></tr></tbody></table>

{% tabs %}
{% tab title="200: OK OK" %}

```json
{
    "Code": 0,
    "TaskId": 123456,
    "Message": "OK"
}
```

{% endtab %}

{% tab title="200: OK FAILED" %}

```json
{
    "Code": 1,
    "Message": "Error description"
}
```

{% endtab %}
{% endtabs %}

## Get result

<mark style="color:blue;">`GET`</mark> `https://hmcaptcha.com/getResult?apikey={your_apikey}&taskid={taskid}`

**Example** `https://hmcaptcha.com/getResult?apikey=admin_goiZ4dxa1GNHHRt0He8KEnrfYJCz3JE&taskid=12345`

#### Query Parameters

| Name                                     | Type   | Description                          |
| ---------------------------------------- | ------ | ------------------------------------ |
| apikey<mark style="color:red;">\*</mark> | String | The user apikey. Get it in dashboard |
| taskid<mark style="color:red;">\*</mark> | String | The task id from Create Task step    |

{% tabs %}
{% tab title="200: OK PENDING " %}

```json
{
    "Code": 0,
    "Status": "PENDING",
    "Data": null
}
```

{% endtab %}

{% tab title="200: OK PROCESSING" %}

```json
{
    "Code": 0,
    "Status": "PROCESSING",
    "Data": null
}
```

{% endtab %}

{% tab title="200: OK ERROR" %}

```json
{
    "Code": 0,
    "Status": "ERROR",
    "Message": "Error message detail"
    "Data": null
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="200: OK SUCCESS (slide)" %}

```json
{
    "Code": 0,
    "Status": "SUCCESS",
    "Data": {
            "offset": 78, // Drag to right 78px
            "x": 210,
            "y": 652 // point button slide
        }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="200: OK SUCCESS (2 obj)" %}

```json
{
    "Code": 0,
    "Status": "SUCCESS",
    "Data": {
            "x1y1x2y2":"678|427|540|564",
            "raw":"0.61413,0.62064|0.48913,0.819767" // x1,y1|x2,y2 ...
        }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="200: OK SUCCESS (rotate web)" %}

```json
{
    "Code": 0,
    "Status": "SUCCESS",
    "Data": {
            "angle": 78
        }
}
```

{% endtab %}

{% tab title="200: OK SUCCESS (rotate app)" %}

```json
{
    "Code": 0,
    "Status": "SUCCESS",
    "Data": {
            "angle": 78,
            "point_slide": {"x": 210, "y": 652} // point button slide
        }
}
```

{% endtab %}
{% endtabs %}

### Hướng dẫn thêm cho captcha xoay

* Kết quả nhận được sau khi giải là độ (angle), muốn chuyển đổi sang pixel để kéo cần tính theo công thức sau:&#x20;

```python
# Tính offset
offset = angle * width * 0.00446837493
# hoặc
offset = angle * (width_slide/180)
```

* Với width (độ rộng thanh trượt) được lấy như ảnh sau:

<div><figure><img src="/files/Vw9vOe3jgiGb0uPhlCxR" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="/files/pJtNo9mMbHS5Z8LDp1pN" alt="" width="375"><figcaption></figcaption></figure></div>

```python
# Some code (TIKTOK_ROTATE_APP)
response = {
    "Code": 0,
    "Status": "SUCCESS",
    "Data": {
            "angle": 78,
            "point_slide": {"x": 210, "y": 652} // point button slide
        }
}

# Lấy kết quả 'angle' trong phản hồi
angle = response["Data"]["angle"]

# Tính offset
# offset = angle * width * 0.00446837493
# hoặc
offset = angle * (width_slide/180)

# Tính lại tọa độ để kéo (trên app tiktok)
x1 = response["Data"]["point_slide"]["x"]
y1 = y2 = response["Data"]["point_slide"]["y"]
x2 = x1 + offset

ADB_exec(f"adb shell input touchscreen swipe {x1} {y1} {x2} {y2}")
```

### Hướng dẫn thêm cho captcha chọn đối tượng giống nhau

* Kết quả nhận được: `{"raw": "0.61413,0.62064|0.48913,0.819767"}`  // x1,y1|x2,y2 ...
* Tính tọa độ click như sau:

```python
# Some code (TIKTOK_OBJ)
response = {
    "raw": "0.61413,0.62064|0.48913,0.819767"
}
for pn in response['raw'].split('|'):
    xn, yn = pn.split(',')
    xn, yn = float(xn), float(yn)
    x = int(xn * image.renderWidth)
    y = int(xn * image.renderHeight)
    click(x, y)
```

<figure><img src="/files/G6hzUTd3zLZ844OUVSMu" alt=""><figcaption></figcaption></figure>

### Hướng dẫn thêm cho captcha slide trên phone

```python
# Tiktok thêm một số tỉ lệ khiến cho kéo theo offset không chính xác
# (kéo 45px nhưng mảnh ghép chạy đến 57px rồi)
# Nếu bị thì fix bằng công thức sau
offset = offset * (45 / 57)

```
