Documents API
문서 관리 및 RDF 데이터 업로드를 위한 API입니다.
개요
Documents API를 통해 D.Hub에서 문서를 관리하고, RDF 형식의 지식 그래프 데이터를 Neo4j에 업로드할 수 있습니다.
엔드포인트
GET /api/v1/documents/
모든 문서 목록을 조회합니다.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | integer | 100 | 최대 조회 개수 |
token | string | - | 페이지네이션 토큰 |
groups | string | - | 그룹 필터 (쉼표로 구분) |
Response
200 OK
{
"items": {
"document-abc123": "{\"id\":\"document-abc123\",\"name\":\"Knowledge Graph\",...}",
"document-xyz789": "{\"id\":\"document-xyz789\",\"name\":\"Ontology Data\",...}"
},
"token": "next-page-token"
}
GET /api/v1/documents/{document_id}/versions
문서의 버전 히스토리를 조회합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | 문서 ID |
Response
200 OK
[
{
"version_id": "v2",
"last_modified": "2024-01-20T10:30:00Z",
"size": 2048
}
]
GET /api/v1/documents/{document_id}
특정 문서를 조회합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | 문서 ID |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_version | string | No | 특정 버전 조회 |
Response
200 OK
{
"id": "document-abc123",
"name": "Product Ontology",
"alias": "product-ontology",
"type": "rdf",
"groups": ["products"],
"tags": ["ontology", "knowledge-graph"],
"options": {},
"nodes": [],
"relations": ["hasCategory", "belongsTo", "relatedTo"],
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-20T10:30:00Z"
}
POST /api/v1/documents/
새 문서를 생성합니다.
Request Body
{
"name": "Product Ontology",
"alias": "product-ontology",
"type": "rdf",
"groups": ["products"],
"tags": ["ontology"]
}
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | 문서 이름 |
alias | string | No | 별칭 |
type | string | No | 문서 타입 (기본: rdf) |
groups | array | No | 그룹 목록 |
tags | array | No | 태그 목록 |
options | object | No | 추가 옵션 |
Response
200 OK
{
"item": "document-abc123"
}
PUT /api/v1/documents/{document_id}
문서 정보를 수정합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | 문서 ID |
Request Body
{
"name": "Updated Name",
"tags": ["updated-tag"]
}
| Field | Type | Description |
|---|---|---|
name | string | 문서 이름 |
alias | string | 별칭 |
type | string | 문서 타입 |
groups | array | 그룹 목록 |
tags | array | 태그 목록 |
options | object | 추가 옵션 |
comment | string | 버전 코멘트 |
Response
200 OK
{
"message": "Document updated successfully"
}
DELETE /api/v1/documents/{document_id}
문서를 삭제합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | 문서 ID |
Response
200 OK
{
"message": "Document deleted successfully"
}
PUT /api/v1/documents/{document_id}/upload
RDF 파일을 업로드하고 Neo4j에 적재합니다.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | 문서 ID |
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
format | string | rdf | 파일 형식 |
mode | string | append | 적재 모드 |
batches | integer | 1000 | 배치 크기 |
Request Body
multipart/form-data 형식으로 파일을 업로드합니다.
| Field | Type | Description |
|---|---|---|
file | file | RDF 파일 (.rdf, .ttl, .n3) |
Response
200 OK
{
"message": "Document uploaded successfully"
}
RDF 파일 처리
업로드된 RDF 파일은 파싱되어:
- 노드(Resource)가 Neo4j에 생성됩니다.
- 속성(Attribute)이 노드에 설정됩니다.
- 관계(Relation)가 노드 간에 생성됩니다.
지원 RDF 형식
| Format | Extension | Description |
|---|---|---|
| RDF/XML | .rdf | 표준 RDF XML 형식 |
| Turtle | .ttl | 간결한 텍스트 형식 |
| N-Triples | .nt | 라인 기반 형식 |
| N3 | .n3 | Notation 3 형식 |
사용 예시
cURL
# 문서 목록 조회
curl https://api.dhub.io/api/v1/documents/ \
-H "Authorization: Bearer <access_token>"
# 문서 생성
curl -X POST https://api.dhub.io/api/v1/documents/ \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Product Ontology",
"type": "rdf",
"groups": ["products"]
}'
# RDF 파일 업로드
curl -X PUT "https://api.dhub.io/api/v1/documents/document-abc123/upload?format=rdf" \
-H "Authorization: Bearer <access_token>" \
-F "file=@ontology.rdf"