Documents API
API for document management and RDF data upload.
Overview
Through the Documents API, you can manage documents in D.Hub and upload RDF format knowledge graph data to Neo4j.
Endpoints
GET /api/v1/documents/
Retrieves a list of all documents.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | integer | 100 | Maximum number of items to retrieve |
token | string | - | Pagination token |
groups | string | - | Group filter (comma-separated) |
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
Retrieves the version history of a document.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | Document ID |
Response
200 OK
[
{
"version_id": "v2",
"last_modified": "2024-01-20T10:30:00Z",
"size": 2048
}
]
GET /api/v1/documents/{document_id}
Retrieves a specific document.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | Document ID |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_version | string | No | Retrieve specific version |
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/
Creates a new document.
Request Body
{
"name": "Product Ontology",
"alias": "product-ontology",
"type": "rdf",
"groups": ["products"],
"tags": ["ontology"]
}
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Document name |
alias | string | No | Alias |
type | string | No | Document type (default: rdf) |
groups | array | No | List of groups |
tags | array | No | List of tags |
options | object | No | Additional options |
Response
200 OK
{
"item": "document-abc123"
}
PUT /api/v1/documents/{document_id}
Updates document information.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | Document ID |
Request Body
{
"name": "Updated Name",
"tags": ["updated-tag"]
}
| Field | Type | Description |
|---|---|---|
name | string | Document name |
alias | string | Alias |
type | string | Document type |
groups | array | List of groups |
tags | array | List of tags |
options | object | Additional options |
comment | string | Version comment |
Response
200 OK
{
"message": "Document updated successfully"
}
DELETE /api/v1/documents/{document_id}
Deletes a document.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | Document ID |
Response
200 OK
{
"message": "Document deleted successfully"
}
PUT /api/v1/documents/{document_id}/upload
Uploads an RDF file and loads it into Neo4j.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
document_id | string | Yes | Document ID |
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
format | string | rdf | File format |
mode | string | append | Load mode |
batches | integer | 1000 | Batch size |
Request Body
Upload file in multipart/form-data format.
| Field | Type | Description |
|---|---|---|
file | file | RDF file (.rdf, .ttl, .n3) |
Response
200 OK
{
"message": "Document uploaded successfully"
}
RDF File Processing
Uploaded RDF files are parsed and:
- Nodes (Resources) are created in Neo4j.
- Attributes are set on nodes.
- Relations are created between nodes.
Supported RDF Formats
| Format | Extension | Description |
|---|---|---|
| RDF/XML | .rdf | Standard RDF XML format |
| Turtle | .ttl | Concise text format |
| N-Triples | .nt | Line-based format |
| N3 | .n3 | Notation 3 format |
Usage Examples
cURL
# List documents
curl https://api.dhub.io/api/v1/documents/ \
-H "Authorization: Bearer <access_token>"
# Create document
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"]
}'
# Upload RDF file
curl -X PUT "https://api.dhub.io/api/v1/documents/document-abc123/upload?format=rdf" \
-H "Authorization: Bearer <access_token>" \
-F "file=@ontology.rdf"