> 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/zh/apis/ontologies-api.md).

# 本体 API

Unitlab 本体 API（Ontologies API）：通过 HTTP 列出、读取、创建和替换工作区本体，包含筛选参数、JSON 结构和所需权限。

| 方法与路由                           | 作用                    | 权限                |
| ------------------------------- | --------------------- | ----------------- |
| `GET /api/sdk/ontologies/`      | 列出本体（分页）              | View ontology     |
| `POST /api/sdk/ontologies/`     | 创建本体                  | Manage ontologies |
| `GET /api/sdk/ontologies/{id}/` | 读取本体                  | View ontology     |
| `PUT /api/sdk/ontologies/{id}/` | 替换其标题、描述和结构，并记录一个修订版本 | Manage ontologies |

列表筛选参数：`title_eq`、`title_like`、`desc_eq`、`desc_like`、`created_before`、`created_after`、`edited_before`、`edited_after`（ISO 8601）。

```bash
curl -s -X POST https://api.unitlab.ai/api/sdk/ontologies/ \
  -H "Authorization: Api-Key $UNITLAB_API_KEY" -H "Content-Type: application/json" \
  -d @ontology.json
```

```json
{
  "title": "Robot cell QA",
  "description": "Grippers and parts",
  "data_type": "image",
  "structure": {"objects": [], "classifications": [], "skeleton_templates": []}
}
```

响应中的 `ontology_hash` 即本体 ID，创建项目时传入它。可用 SDK 的 `OntologyStructure` 和 `to_dict()` 构建 `structure`，或从现有本体中复制。参见 [用 Python 构建本体](https://docs.unitlab.ai/api-sdk-cli/zh/sdks/build-ontologies-in-python.md)。

## 相关内容 <a href="#related" id="related"></a>

[SDK：本体资源](https://docs.unitlab.ai/api-sdk-cli/zh/sdks/ontology-resources.md) · [项目 API](https://docs.unitlab.ai/api-sdk-cli/zh/apis/projects-api.md)
