> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xhuoapi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Artistic QR Tasks API의 연동 및 사용

> Art QR Code Generation 集成指南 - XHuoAPI

Artistic QR Tasks API의 주요 기능은 Artistic QR Generation API에서 생성된 작업 ID를 입력하여 해당 작업의 실행 상태를 조회하는 것입니다.

본 문서는 Artistic QR Tasks API의 연동 설명을 자세히 소개하여, 귀하가 이 API의 강력한 기능을 쉽게 통합하고 충분히 활용할 수 있도록 돕습니다. Artistic QR Tasks API를 통해 Artistic QR Generation API의 작업 실행 상태를 쉽게 조회할 수 있습니다.

## 신청 절차

Artistic QR Tasks API를 사용하려면 먼저 신청 페이지 [Artistic QR Generation API](https://api.xhuoapi.ai/documents/ee085d2a-a0b9-4f0e-8b4d-8da407345138)에서 해당 서비스를 신청한 후, Artistic QR Generation API의 작업 ID를 복사합니다. 아래 그림과 같이:

<p>
  <img src="https://cdn.xhuoapi.ai/2wicjy.png" width="500" className="m-auto" />
</p>

마지막으로 Artistic QR Tasks API 페이지 [Artistic QR Tasks API](https://api.xhuoapi.ai/documents/21de9d76-6e39-4ac3-b8b9-20e7194c02b4)에서 해당 서비스를 신청하고, 페이지에 들어가면 "Acquire" 버튼을 클릭합니다. 아래 그림과 같이:

![신청 페이지](https://cdn.xhuoapi.ai/rci31i.png)

로그인 또는 등록이 되어 있지 않으면 자동으로 [로그인 페이지](https://api.xhuoapi.ai)로 이동하여 등록 및 로그인을 요청합니다. 로그인 및 등록 후에는 자동으로 현재 페이지로 돌아옵니다.

첫 신청 시 무료 한도가 제공되어, 해당 API를 무료로 사용할 수 있습니다.

## 요청 예시

Artistic QR Tasks API는 Artistic QR Generation API의 결과를 조회하는 데 사용될 수 있습니다. Artistic QR Generation API의 사용 방법에 대한 자세한 내용은 문서 [Artistic QR Generation API](https://api.xhuoapi.ai/documents/ee085d2a-a0b9-4f0e-8b4d-8da407345138)를 참조하십시오.

우리는 Artistic QR Generation API 서비스에서 반환된 작업 ID 하나를 예로 들어, 해당 API를 사용하는 방법을 시연합니다. 가정해 보겠습니다, 작업 ID가 e2c65b20-a970-431e-99c1-76721e799df8입니다. 다음으로 작업 ID를 전달하여 사용하는 방법을 시연합니다.

### 작업 예시 그림

<p>
  <img src="https://cdn.xhuoapi.ai/2wicjy.png" width="500" className="m-auto" />
</p>

### 요청 헤더 및 요청 본문 설정

**Request Headers**에는 다음이 포함됩니다:

* `accept`: JSON 형식의 응답 결과를 수신하도록 지정하며, 여기서는 `application/json`으로 입력합니다.
* `authorization`: API 호출에 필요한 키로, 신청 후 직접 드롭다운에서 선택할 수 있습니다.

**Request Body**에는 다음이 포함됩니다:

* `id`: 업로드된 작업 ID.
* `action`: 작업의 조작 방식.

아래 그림과 같이 설정합니다:

<p>
  <img src="https://cdn.xhuoapi.ai/use825.png" width="500" className="m-auto" />
</p>

### 코드 예시

페이지 오른쪽에서 다양한 언어의 코드가 자동으로 생성된 것을 확인할 수 있습니다. 아래 그림과 같이:

<p>
  <img src="https://cdn.xhuoapi.ai/jejwy6.png" width="500" className="m-auto" />
</p>

일부 코드 예시는 다음과 같습니다:

#### CURL

```bash theme={null}
curl -X POST 'https://api.xhuoapi.ai/v1/qrart/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "id": "e2c65b20-a970-431e-99c1-76721e799df8",
  "action": "retrieve"
}'
```

#### Python

```python theme={null}
import requests

url = "https://api.xhuoapi.ai/v1/qrart/tasks"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "id": "e2c65b20-a970-431e-99c1-76721e799df8",
    "action": "retrieve"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

### 응답 예시

요청이 성공하면, API는 이곳 QR 코드 작업의 세부 정보를 반환합니다. 예를 들어:

```json theme={null}
{
  "_id": "668cb62c550a4144a582e372",
  "id": "e2c65b20-a970-431e-99c1-76721e799df8",
  "application_id": "3d25be99-4676-44d3-90bb-23086bc25300",
  "created_at": 1720497708.318,
  "credential_id": "6e80fca1-9a49-4507-ae8e-601dbd0ab3ca",
  "request": {
    "aspect_ratio": "1:1",
    "callback_url": null,
    "content": "https://api.xhuoapi.ai",
    "content_image_url": null,
    "ecl": "H",
    "image_origin": null,
    "marker_shape": "square",
    "negative_prompt": null,
    "padding_level": 5,
    "padding_noise": 0,
    "pattern": "custom",
    "pixel_style": "square",
    "position": "center",
    "preset": "",
    "prompt": "mexican tacos",
    "qrw": 2,
    "ratio": null,
    "rotate": 0,
    "seed": null,
    "steps": 20,
    "sub_marker": "square",
    "timeout": null,
    "trace_id": "a99ecc24-eda0-45c6-bb5f-98060c30b490",
    "type": "link"
  },
  "response": {
    "image_url": "https://platform.cdn.xhuoapi.ai/qrart/e2c65b20-a970-431e-99c1-76721e799df8.png",
    "image_width": 768,
    "image_height": 768,
    "seed": 5324369603686616,
    "success": true
  }
}
```

반환 결과는 여러 필드로 구성되어 있으며, request 필드는 작업을 시작할 때의 request body를 나타내고, response 필드는 작업 완료 후 반환된 response body로, 그 결과는 Artistic QR Generation API의 요청 및 반환과 일치합니다. 필드 설명은 다음과 같습니다.

* `id`: 이 QR 코드 작업을 생성한 ID로, 이번 QR 코드 생성 작업을 고유하게 식별하는 데 사용됩니다.
* `request`: QR 코드 작업의 요청 정보를 조회합니다.
* `response`: QR 코드 작업의 반환 정보를 조회합니다.

## 배치 조회 작업

이는 여러 QR 코드 작업 ID에 대해 QR 코드 작업 세부 정보를 조회하는 것으로, 위와 다른 점은 action을 retrieve\_batch로 선택해야 한다는 것입니다.

**Request Body**에는 다음이 포함됩니다:

* `ids`: 업로드된 작업 ID 배열.
* `action`: 작업의 조작 방식.

아래 그림과 같이 설정합니다:

<p>
  <img src="https://cdn.xhuoapi.ai/mrbxmr.png" width="500" className="m-auto" />
</p>

### 코드 예시

페이지 오른쪽에서 다양한 언어의 코드가 자동으로 생성된 것을 확인할 수 있습니다. 아래 그림과 같이:

<p>
  <img src="https://cdn.xhuoapi.ai/u3b61d.png" width="500" className="m-auto" />
</p>

일부 코드 예시는 다음과 같습니다:

### 응답 예시

요청이 성공하면, API는 이번 모든 배치 QR 코드 작업의 구체적인 세부 정보를 반환합니다. 예를 들어:

```json theme={null}
{
  "items": [
    {
      "_id": "668cb90e550a4144a5834557",
      "id": "8c89e97b-6a79-4406-b2ce-e00f92540b4e",
      "application_id": "3d25be99-4676-44d3-90bb-23086bc25300",
      "created_at": 1720498446.039,
      "credential_id": "b7f9aaa1-43d8-471f-a826-cd0f4733fec5",
      "request": {
        "aspect_ratio": "1:1",
        "callback_url": null,
        "content": "https://huyinfu.space",
        "content_image_url": null,
        "ecl": "H",
        "image_origin": null,
        "marker_shape": "square",
        "negative_prompt": null,
        "padding_level": 5,
        "padding_noise": 0,
        "pattern": "custom",
        "pixel_style": "square",
        "position": "center",
        "preset": "",
        "prompt": "멕시코 타코",
        "qrw": 2,
        "ratio": null,
        "rotate": 0,
        "seed": null,
        "steps": 20,
        "sub_marker": "square",
        "timeout": null,
        "trace_id": "44d33486-0527-451f-afc2-df11aab7e049",
        "type": "link"
      },
      "response": {
        "image_url": "https://platform.cdn.xhuoapi.ai/qrart/8c89e97b-6a79-4406-b2ce-e00f92540b4e.png",
        "image_width": 768,
        "image_height": 768,
        "seed": 2701847236953402,
        "success": true
      }
    },
    {
      "_id": "668cb62c550a4144a582e372",
      "id": "e2c65b20-a970-431e-99c1-76721e799df8",
      "application_id": "3d25be99-4676-44d3-90bb-23086bc25300",
      "created_at": 1720497708.318,
      "credential_id": "6e80fca1-9a49-4507-ae8e-601dbd0ab3ca",
      "request": {
        "aspect_ratio": "1:1",
        "callback_url": null,
        "content": "https://api.xhuoapi.ai",
        "content_image_url": null,
        "ecl": "H",
        "image_origin": null,
        "marker_shape": "square",
        "negative_prompt": null,
        "padding_level": 5,
        "padding_noise": 0,
        "pattern": "custom",
        "pixel_style": "square",
        "position": "center",
        "preset": "",
        "prompt": "멕시코 타코",
        "qrw": 2,
        "ratio": null,
        "rotate": 0,
        "seed": null,
        "steps": 20,
        "sub_marker": "square",
        "timeout": null,
        "trace_id": "a99ecc24-eda0-45c6-bb5f-98060c30b490",
        "type": "link"
      },
      "response": {
        "image_url": "https://platform.cdn.xhuoapi.ai/qrart/e2c65b20-a970-431e-99c1-76721e799df8.png",
        "image_width": 768,
        "image_height": 768,
        "seed": 5324369603686616,
        "success": true
      }
    }
  ],
  "count": 2
}
```

#### CURL

```bash theme={null}
curl -X POST 'https://api.xhuoapi.ai/v1/qrart/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "ids": ["8c89e97b-6a79-4406-b2ce-e00f92540b4e","e2c65b20-a970-431e-99c1-76721e799df8"],
  "action": "retrieve_batch"
}'
```

#### Python

```python theme={null}
import requests

url = "https://api.xhuoapi.ai/v1/qrart/tasks"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "ids": ["8c89e97b-6a79-4406-b2ce-e00f92540b4e","e2c65b20-a970-431e-99c1-76721e799df8"],
    "action": "retrieve_batch"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)
```

## 오류 처리

API를 호출할 때 오류가 발생하면, API는 해당 오류 코드와 정보를 반환합니다. 예를 들어:

* `400 token_mismatched`：잘못된 요청, 누락되었거나 잘못된 매개변수로 인한 것일 수 있습니다.
* `400 api_not_implemented`：잘못된 요청, 누락되었거나 잘못된 매개변수로 인한 것일 수 있습니다.
* `401 invalid_token`：권한 없음, 잘못되었거나 누락된 인증 토큰입니다.
* `429 too_many_requests`：요청이 너무 많음, 비율 제한을 초과했습니다.
* `500 api_error`：내부 서버 오류, 서버에서 문제가 발생했습니다.

### 오류 응답 예시

```
{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}
```

## 결론

이 문서를 통해 Artistic QR Tasks API를 사용하여 단일 또는 배치 QR 코드 작업의 모든 구체적인 세부 정보를 조회하는 방법을 이해하셨습니다. 이 문서가 API를 더 잘 연결하고 사용하는 데 도움이 되기를 바랍니다. 질문이 있으시면 언제든지 기술 지원 팀에 문의해 주십시오.
