> For the complete documentation index, see [llms.txt](https://docs.unitlab.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unitlab.ai/api-sdk-cli/ko/apis/project-data-and-batch-queues-api.md).

# 프로젝트 데이터와 Batch Queue API

Unitlab HTTP API로 파일을 업로드하고, Batch Queue 처리 상태를 추적하고, Data Unit을 조회하고, 클라우드에서 가져오거나 라이브러리 데이터를 연결하는 방법입니다.

## 라우트 <a href="#routes" id="routes"></a>

| 메서드와 라우트                                                         | 하는 일                 |
| ---------------------------------------------------------------- | -------------------- |
| `POST projects/{id}/upload-data/`                                | 파일 하나 업로드(multipart) |
| `GET projects/{id}/upload-sessions/`                             | Batch Queue 목록(페이지)  |
| `GET projects/{id}/upload-sessions/{bq}/`                        | Batch Queue 하나 조회    |
| `GET projects/{id}/upload-sessions/{bq}/status/`                 | 처리 건수                |
| `GET projects/{id}/upload-sessions/{bq}/data/`                   | 파일과 처리 상태(페이지)       |
| `GET projects/{id}/data-units/`                                  | 작업 항목(페이지)           |
| `GET projects/{id}/data-units/{unit}/`                           | 작업 항목 하나             |
| `POST projects/{id}/cloud-storages/{storage}/import/`            | 클라우드 파일 가져오기         |
| `POST projects/{id}/attach-data/preview/`, `attach-data/commit/` | 라이브러리 폴더와 데이터셋 버전 연결 |
| `GET projects/{id}/attached-sources/`                            | 연결된 소스               |
| `POST projects/{id}/attached-sources/{link}/detach/`             | 소스 연결 해제             |

모든 라우트는 `https://api.unitlab.ai/api/sdk/` 아래에 있습니다. 업로드와 조회에는 **Manage data** 권한이 필요하고(조회는 **View labeling interface**로도 가능), 연결에는 **Manage projects** 권한이 필요합니다.

## 파일 업로드 <a href="#upload-a-file" id="upload-a-file"></a>

Batch Queue에 사용할 새 UUID를 하나 정하고, 업로드의 모든 파일을 그 값과 함께 보냅니다.

```bash
BQ=$(uuidgen | tr 'A-Z' 'a-z')
for f in ./cell-04/*.jpg; do
  curl -s -X POST "https://api.unitlab.ai/api/sdk/projects/$PROJECT_ID/upload-data/" \
    -H "Authorization: Api-Key $UNITLAB_API_KEY" \
    -F "file=@$f" --form-string "session_id=$BQ"
done
```

```json
{"datasource_id": "4dcd6421-db13-45cb-98f7-babca5944e22", "upload_session_id": "a09a5c4e-...", "generic_type": "img"}
```

| 필드             | 용도                                          |
| -------------- | ------------------------------------------- |
| `file`         | 파일. 필수입니다.                                  |
| `session_id`   | Batch Queue ID. 같은 ID를 가진 파일은 하나의 업로드가 됩니다. |
| `fps`          | 비디오 초당 프레임 수                                |
| `generic_type` | `tabular` 등 유형을 강제로 지정                      |

이 라우트는 일반 요청 크기까지의 파일만 받습니다. 64 MiB를 넘는 비디오, 오디오, 의료, PDF 파일과 대용량 래스터, LiDAR 씬은 분할(multipart) 라우트(`tiled-uploads/`, `pointcloud-uploads/`)를 사용합니다. 이런 파일은 분할과 재시도를 처리해 주는 SDK나 CLI를 사용하세요.

## 처리 상태 추적 <a href="#follow-processing" id="follow-processing"></a>

```bash
curl -s "https://api.unitlab.ai/api/sdk/projects/$PROJECT_ID/upload-sessions/$BQ/status/" \
  -H "Authorization: Api-Key $UNITLAB_API_KEY"
```

```json
{"status": "completed", "total": 1, "completed": 1, "processing": 0, "failed": 0}
```

`status`는 `processing`, `completed`, `partial_failure`, `failed` 중 하나입니다. `processing`이 0이 될 때까지 1, 2, 4, 8초 후 10\~20초마다처럼 간격을 늘려 가며 폴링합니다. 그다음 `/data/`로 실패한 파일을 나열합니다. 각 행에는 `file_name`, `generic_type`, `upload_status`가 있습니다.

## Data Unit 목록 <a href="#list-data-units" id="list-data-units"></a>

```bash
curl -s "https://api.unitlab.ai/api/sdk/projects/$PROJECT_ID/data-units/?batch_queue=$BQ&status=annotate&limit=100" \
  -H "Authorization: Api-Key $UNITLAB_API_KEY"
```

필터: `search`, `data_type`, `status`, `batch_queue`, `kind`(`datasource` 또는 `group`). 각 행에는 `id`, `kind`, `name`, `data_type`, `status`, `workflow_task_id`, `stage_id`, `assigned_to_id`, `batch_queue_id`, `file_size`, `thumbnail_url`, `metadata`가 있고, 그룹이면 `items`도 있습니다.

## 클라우드 스토리지에서 가져오기 <a href="#import-from-cloud-storage" id="import-from-cloud-storage"></a>

```bash
curl -s -X POST "https://api.unitlab.ai/api/sdk/projects/$PROJECT_ID/cloud-storages/$STORAGE_ID/import/" \
  -H "Authorization: Api-Key $UNITLAB_API_KEY" -H "Content-Type: application/json" \
  -d '{"server_files": ["fleet/cell-04/2026-11-21/", "fleet/calib.png"], "fps": 2}'
```

응답에는 `upload_session_id`(Batch Queue)와 `file_count`가 들어 있습니다.

## 라이브러리 데이터 연결 <a href="#attach-library-data" id="attach-library-data"></a>

```json
{
  "folder_ids": ["FOLDER_ID"],
  "dataset_ids": [],
  "dataset_versions": [{"dataset_id": "DATASET_ID", "version_number": 2}],
  "fps": 1,
  "publish_unpublished": false
}
```

같은 본문을 `attach-data/preview/`에 POST해 건수를 확인한 뒤 `attach-data/commit/`에 POST합니다. 연결이 진행되는 동안 같은 프로젝트에 두 번째 연결을 요청하면 409로 응답합니다.

## 관련 문서 <a href="#related" id="related"></a>

[SDK: 프로젝트 업로드](https://docs.unitlab.ai/api-sdk-cli/ko/sdks/project-uploads.md) · [SDK: 연결과 연결 해제](https://docs.unitlab.ai/api-sdk-cli/ko/sdks/attach-and-detach-project-sources.md) · [오류, 요청 한도, 페이지네이션](https://docs.unitlab.ai/api-sdk-cli/ko/apis/errors-rate-limits-and-pagination.md)
