-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
The OntoKit API is a RESTful JSON API. Interactive documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
http://localhost:8000/api/v1
Most endpoints require authentication via Bearer token:
curl -H "Authorization: Bearer <access_token>" \
http://localhost:8000/api/v1/projectsSee Authentication for details on obtaining tokens.
| Code | Description |
|---|---|
| 200 | Success |
| 201 | Created |
| 204 | No Content (successful deletion) |
| 400 | Bad Request (validation error) |
| 401 | Unauthorized (missing/invalid token) |
| 403 | Forbidden (insufficient permissions) |
| 404 | Not Found |
| 500 | Internal Server Error |
Check if the API is running.
Response:
{
"status": "healthy"
}GET /api/v1/projects
List projects accessible to the current user.
Query Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
skip |
int | 0 | Pagination offset |
limit |
int | 20 | Max results (1-100) |
filter |
string | null | Filter: public, mine, or null for all accessible |
Response:
{
"items": [
{
"id": "uuid",
"name": "Project Name",
"description": "Optional description",
"is_public": true,
"owner_id": "user-id",
"owner": {
"id": "user-id",
"name": "User Name",
"email": "user@example.com"
},
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-02T00:00:00Z",
"member_count": 3,
"user_role": "owner"
}
],
"total": 1,
"skip": 0,
"limit": 20
}POST /api/v1/projects
Create a new project. Requires authentication.
Request Body:
{
"name": "My Project",
"description": "Optional description",
"is_public": false
}Response: 201 Created with the created project.
GET /api/v1/projects/{project_id}
Get a project by ID.
Response: Project object or 403 if private and user lacks access.
PATCH /api/v1/projects/{project_id}
Update project settings. Requires owner or admin role.
Request Body:
{
"name": "New Name",
"description": "New description",
"is_public": true
}All fields are optional.
DELETE /api/v1/projects/{project_id}
Delete a project. Requires owner role.
Response: 204 No Content
GET /api/v1/projects/{project_id}/members
List members of a project. Requires membership.
Response:
{
"items": [
{
"id": "uuid",
"project_id": "uuid",
"user_id": "user-id",
"role": "owner",
"user": {
"id": "user-id",
"name": "User Name",
"email": "user@example.com"
},
"created_at": "2024-01-01T00:00:00Z"
}
],
"total": 1
}POST /api/v1/projects/{project_id}/members
Add a member to a project. Requires owner or admin role.
Request Body:
{
"user_id": "user-id-to-add",
"role": "editor"
}Roles: admin, editor, viewer (cannot add as owner)
PATCH /api/v1/projects/{project_id}/members/{user_id}
Update a member's role. Requires owner or admin role.
Request Body:
{
"role": "admin"
}DELETE /api/v1/projects/{project_id}/members/{user_id}
Remove a member from a project. Owner/admin can remove others; users can remove themselves.
Response: 204 No Content
POST /api/v1/auth/device/code
Start the OAuth2 Device Authorization flow.
Request Body:
{
"client_id": "your-client-id"
}Response:
{
"device_code": "...",
"user_code": "ABCD-1234",
"verification_uri": "http://localhost:8080/device",
"expires_in": 600,
"interval": 5
}POST /api/v1/auth/device/token
Poll for the access token after user authorization.
Request Body:
{
"client_id": "your-client-id",
"device_code": "..."
}Response (success):
{
"access_token": "...",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "..."
}Response (pending):
{
"error": "authorization_pending"
}POST /api/v1/auth/token/refresh?refresh_token={token}
Refresh an access token.
Note: Ontology endpoints are currently in development.
GET /api/v1/ontologies
POST /api/v1/ontologies
GET /api/v1/ontologies/{ontology_id}
Supports content negotiation via Accept header:
-
text/turtle(default) application/rdf+xmlapplication/ld+json
PUT /api/v1/ontologies/{ontology_id}
DELETE /api/v1/ontologies/{ontology_id}
POST /api/v1/ontologies/{ontology_id}/import
Upload an ontology file (multipart form data).
GET /api/v1/ontologies/{ontology_id}/export?format=turtle
GET /api/v1/search?q={query}
POST /api/v1/search/sparql
Request Body:
{
"query": "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10",
"timeout": 30
}All errors follow this format:
{
"detail": "Error message describing what went wrong"
}For validation errors:
{
"detail": [
{
"loc": ["body", "name"],
"msg": "field required",
"type": "value_error.missing"
}
]
}Currently, there is no rate limiting in development mode. Production deployments should implement rate limiting at the infrastructure level (e.g., nginx, API gateway).
- Authentication - How to authenticate
- Development - Development workflow