Public API Endpoints
Overview
This page documents the public API endpoints exposed by DeepDoc, grouped by resource family. These endpoints provide health checks, chatbot query capabilities, report retrieval, and user management operations. They are intended for use by both internal services and external clients integrating with DeepDoc.
The main runtime and chatbot engine logic is implemented in the Runtime Services & Chatbot Engine module.
All endpoints documented here are grounded in the actual handler code found in deepdoc/chatbot/service.py, deepdoc/chatbot/scaffold.py, and tests/fixtures/frameworks/django_app/urls.py.
API Request Lifecycle
For a detailed breakdown of the runtime and chatbot engine, see Runtime Services & Chatbot Engine.
Authentication
Health check and public query endpoints do not require authentication by default, as seen in deepdoc/chatbot/service.py:514 and deepdoc/chatbot/scaffold.py:30. The Django-based endpoints in tests/fixtures/frameworks/django_app/urls.py do not show explicit authentication decorators or middleware in the provided evidence.
If you deploy these endpoints in production, you must add authentication and authorization middleware as appropriate for your environment. See your framework's security documentation.
Endpoints
Health Check Endpoints
GET /health
Handlers:
health()(deepdoc/chatbot/service.py:529)_health()(deepdoc/chatbot/scaffold.py:57)health()(tests/fixtures/frameworks/django_app/urls.py:9)
Returns a simple status indicator for service health.
Parameters
| Location | Name | Type | Required | Description |
|---|---|---|---|---|
| — | — | — | — | No parameters |
Response
| Field | Type | Description |
|---|---|---|
| status | string | "ok" if healthy, "error" if startup failed |
| detail | string | Error detail (only present if startup failed) |
Example
curl https://api.deepdoc.com/health{ "status": "ok" }If startup failed (scaffold fallback):
{ "status": "error", "detail": "ImportError: ..." }Errors
| Status | Condition |
|---|---|
| 503 | Service startup failed (scaffold fallback) |
| 200 | Always returns 200 if healthy |
POST /health
Handler: health() (tests/fixtures/frameworks/django_app/urls.py:9)
No implementation details are present in the evidence. The POST method is registered but its behavior is unknown.
Parameters
No parameters documented.
Response
No response schema documented.
Errors
| Status | Condition |
|---|---|
| — | Not specified in evidence |
Chatbot Query Endpoints
POST /query
Handlers:
query()(deepdoc/chatbot/service.py:533)_query()(deepdoc/chatbot/scaffold.py:61)
Submits a natural language question to the DeepDoc chatbot and receives a grounded, context-rich answer with citations.
Parameters
| Location | Name | Type | Required | Description |
|---|---|---|---|---|
| body | question | string | yes | The user's question |
| body | history | array of objects | no | Conversation history (list of {role, content}) |
Body Schema (from QueryRequest in deepdoc/chatbot/service.py:18):
{
"question": "How does the query endpoint work?",
"history": [
{"role": "user", "content": "What endpoints are available?"},
{"role": "assistant", "content": "See /health and /query."}
]
}Response
| Field | Type | Description |
|---|---|---|
| answer | string | The chatbot's answer, grounded in code context |
| code_citations | array | List of cited code chunks (dicts) |
| artifact_citations | array | List of cited artifact chunks (dicts) |
| doc_links | array | List of related documentation links |
| used_chunks | integer | Number of context chunks used in the answer |
Example
curl -X POST https://api.deepdoc.com/query \
-H "Content-Type: application/json" \
-d '{"question": "How does the query endpoint work?"}'{
"answer": "The /query endpoint processes your question by expanding queries, embedding them, searching across code, artifacts, and docs, reranking results, and composing a detailed answer with citations.",
"code_citations": [
{"file": "deepdoc/chatbot/service.py", "lines": "53-150", "snippet": "..."}
],
"artifact_citations": [],
"doc_links": [
{"title": "Runtime Services & Chatbot Engine", "url": "/runtime-services-chatbot", "doc_path": "runtime-services-chatbot.mdx"}
],
"used_chunks": 5
}Errors
| Status | Condition |
|---|---|
| 500 | Chatbot query failed (e.g., exception in handler) |
| 503 | Service startup failed (scaffold fallback) |
Report Retrieval Endpoint
GET /reports/{slug}
Handler: ReportView.get() (tests/fixtures/frameworks/django_app/urls.py:14)
Retrieves a report by slug. No implementation details are present in the evidence.
Parameters
| Location | Name | Type | Required | Description |
|---|---|---|---|---|
| path | slug | string | yes | Report identifier |
Response
No response schema documented.
Example
curl https://api.deepdoc.com/reports/monthly-summaryErrors
| Status | Condition |
|---|---|
| 404 | Report not found (assumed) |
User Management Endpoints
All user endpoints are handled by UserViewSet (tests/fixtures/frameworks/django_app/urls.py:18), which subclasses ModelViewSet.
GET /api/users
Handler: UserViewSet.list() (tests/fixtures/frameworks/django_app/urls.py:19)
Lists all users.
Parameters
No parameters documented.
Response
No response schema documented.
Example
curl https://api.deepdoc.com/api/usersErrors
| Status | Condition |
|---|---|
| 401 | Unauthorized (if auth enforced) |
POST /api/users
Handler: UserViewSet.create() (tests/fixtures/frameworks/django_app/urls.py:25)
Creates a new user.
Parameters
| Location | Name | Type | Required | Description |
|---|---|---|---|---|
| body | — | object | yes | User creation payload (fields not specified) |
Response
No response schema documented.
Example
curl -X POST https://api.deepdoc.com/api/users \
-H "Content-Type: application/json" \
-d '{"username": "alice", "email": "alice@example.com"}'Errors
| Status | Condition |
|---|---|
| 400 | Invalid input (assumed) |
| 401 | Unauthorized (if auth enforced) |
GET /api/users/{id}
Handler: UserViewSet.retrieve() (tests/fixtures/frameworks/django_app/urls.py:22)
Retrieves a user by ID.
Parameters
| Location | Name | Type | Required | Description |
|---|---|---|---|---|
| path | id | string | yes | User ID |
Response
No response schema documented.
Example
curl https://api.deepdoc.com/api/users/123Errors
| Status | Condition |
|---|---|
| 404 | User not found (assumed) |
| 401 | Unauthorized (if auth enforced) |
DELETE /api/users/{id}
Handler: UserViewSet.destroy() (tests/fixtures/frameworks/django_app/urls.py:28)
Deletes a user by ID.
Parameters
| Location | Name | Type | Required | Description |
|---|---|---|---|---|
| path | id | string | yes | User ID |
Response
No response schema documented.
Example
curl -X DELETE https://api.deepdoc.com/api/users/123Errors
| Status | Condition |
|---|---|
| 404 | User not found (assumed) |
| 401 | Unauthorized (if auth enforced) |
GET /api/users/{id}/stats
Handler: UserViewSet.stats() (tests/fixtures/frameworks/django_app/urls.py:42)
Retrieves statistics for a user by ID.
Parameters
| Location | Name | Type | Required | Description |
|---|---|---|---|---|
| path | id | string | yes | User ID |
Response
No response schema documented.
Example
curl https://api.deepdoc.com/api/users/123/statsErrors
| Status | Condition |
|---|---|
| 404 | User not found (assumed) |
| 401 | Unauthorized (if auth enforced) |
Execution Flow
Chatbot Query (POST /query)
- Request Parsing: The request body is parsed into a
QueryRequest(deepdoc/chatbot/service.py:18). - Service Instantiation:
ChatbotQueryServiceis initialized with the repo root and config (deepdoc/chatbot/service.py:25). - Query Expansion:
_expand_query()(deepdoc/chatbot/service.py:164) may generate alternative queries via LLM ifretrieval_cfg["query_expansion"]is enabled. - Embedding: All queries are embedded in batch using
embedding_client.embed()(frombuild_embedding_client()indeepdoc/chatbot/providers.py:136). - Similarity Search:
_multi_query_search()(deepdoc/chatbot/service.py:186) runs across code, artifact, doc, and relationship corpora. - Chain Retrieval:
_chain_retrieve()(deepdoc/chatbot/service.py:217) pulls in code from related files based on import graphs. - Reranking:
_rerank()(deepdoc/chatbot/service.py:260) optionally reranks chunks using LLM ifretrieval_cfg["rerank"]is enabled. - Prompt Construction:
_build_prompt()(deepdoc/chatbot/service.py:402) assembles the final prompt for the LLM. - Answer Generation: The LLM generates an answer, which is returned with citations and doc links.
- Error Handling: Any exception in the handler returns a 500 with
{"error": "chatbot_query_failed", "detail": ...}.
Conditional Branches & Feature Flags:
query_expansion(config flag): If enabled, alternative queries are generated.rerank(config flag): If enabled, LLM reranking is performed.- If no context is found,
_no_context_result()returns a fallback answer.
Health Endpoints
GET /healthin FastAPI always returns{"status": "ok"}unless the app failed to start, in which case the scaffold fallback returns{"status": "error", "detail": ...}.- No conditional logic or feature flags are present in the health handler.
User/Report Endpoints
- No implementation or branching logic is present in the evidence for user or report endpoints.
State Changes & Side Effects
- Chatbot Query: Reads from vector indexes and corpus files using
load_corpus()andload_vector_index()(deepdoc/chatbot/persistence.py). No writes, cache, or background jobs are triggered by the query endpoint in the provided evidence. - User/Report Endpoints: No database or side effect logic is visible in the evidence.
Constants, Enums & Status Values
- Health Status:
"ok"(healthy),"error"(startup failed). - Chatbot Query Response: No enums, but the response always includes
answer,code_citations,artifact_citations,doc_links, andused_chunks.
See Also
Runtime Services & Chatbot Engine
Details the main runtime services, chatbot engine, and service orchestration.
DeepDoc Chat API Integration
Integration details for the DeepDoc Chat API.
DeepDoc Embedding API Integration
Integration details for the DeepDoc Embedding API.
Referenced files:
deepdoc/chatbot/service.pydeepdoc/chatbot/scaffold.pytests/fixtures/frameworks/django_app/urls.py
For implementation details and service orchestration, see Runtime Services & Chatbot Engine.
endpoint_listing
TODO: This section (endpoint_listing) needs to be filled in with details from the source files listed above.
request_response_examples
TODO: This section (request_response_examples) needs to be filled in with details from the source files listed above.
error_codes
TODO: This section (error_codes) needs to be filled in with details from the source files listed above.