Skip to main content

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

ParameterTypeDefaultDescription
limitinteger100Maximum number of items to retrieve
tokenstring-Pagination token
groupsstring-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

ParameterTypeRequiredDescription
document_idstringYesDocument 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

ParameterTypeRequiredDescription
document_idstringYesDocument ID

Query Parameters

ParameterTypeRequiredDescription
document_versionstringNoRetrieve 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"]
}
FieldTypeRequiredDescription
namestringYesDocument name
aliasstringNoAlias
typestringNoDocument type (default: rdf)
groupsarrayNoList of groups
tagsarrayNoList of tags
optionsobjectNoAdditional options

Response

200 OK

{
"item": "document-abc123"
}

PUT /api/v1/documents/{document_id}

Updates document information.

Path Parameters

ParameterTypeRequiredDescription
document_idstringYesDocument ID

Request Body

{
"name": "Updated Name",
"tags": ["updated-tag"]
}
FieldTypeDescription
namestringDocument name
aliasstringAlias
typestringDocument type
groupsarrayList of groups
tagsarrayList of tags
optionsobjectAdditional options
commentstringVersion comment

Response

200 OK

{
"message": "Document updated successfully"
}

DELETE /api/v1/documents/{document_id}

Deletes a document.

Path Parameters

ParameterTypeRequiredDescription
document_idstringYesDocument 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

ParameterTypeRequiredDescription
document_idstringYesDocument ID

Query Parameters

ParameterTypeDefaultDescription
formatstringrdfFile format
modestringappendLoad mode
batchesinteger1000Batch size

Request Body

Upload file in multipart/form-data format.

FieldTypeDescription
filefileRDF file (.rdf, .ttl, .n3)

Response

200 OK

{
"message": "Document uploaded successfully"
}
RDF File Processing

Uploaded RDF files are parsed and:

  1. Nodes (Resources) are created in Neo4j.
  2. Attributes are set on nodes.
  3. Relations are created between nodes.

Supported RDF Formats

FormatExtensionDescription
RDF/XML.rdfStandard RDF XML format
Turtle.ttlConcise text format
N-Triples.ntLine-based format
N3.n3Notation 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"