API Documentation¶
REST API and WebSocket interface documentation for CodeGraph.
Overview¶
┌─────────────────────────────────────────────────────────────┐
│ API Clients │
└─────────────────────────────┬───────────────────────────────┘
│
┌───────────────────┼───────────────────┐
▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────┐
│ REST API │ │ WebSocket │ │ GraphQL │
│ (HTTP) │ │ (WS) │ │ (Future) │
└───────────┘ └───────────┘ └───────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────┐
│ CodeGraph Backend │
│ Auth | Scenarios | Query | Chat | Review │
└─────────────────────────────────────────────────┘
API Reference¶
| Document |
Description |
| REST API |
Complete HTTP API reference with examples |
| WebSocket API |
Real-time streaming interface |
Quick Start¶
Start API Server¶
python -m src.api.cli run --host 0.0.0.0 --port 8000
Get Authentication Token¶
curl -X POST http://localhost:8000/api/v1/auth/token \
-H "Content-Type: application/json" \
-d '{"username": "admin", "password": "password"}'
Use Token for Requests¶
curl http://localhost:8000/api/v1/scenarios \
-H "Authorization: Bearer <token>"
Authentication¶
All endpoints (except /health) require authentication:
JWT Token¶
curl -H "Authorization: Bearer <token>" \
http://localhost:8000/api/v1/scenarios
API Key¶
curl -H "X-API-Key: <api-key>" \
http://localhost:8000/api/v1/scenarios
API Endpoints¶
Authentication¶
| Method |
Endpoint |
Description |
| POST |
/api/v1/auth/token |
Get JWT token |
| POST |
/api/v1/auth/refresh |
Refresh token |
| POST |
/api/v1/auth/api-keys |
Create API key |
| GET |
/api/v1/auth/me |
Get current user |
Scenarios¶
| Method |
Endpoint |
Description |
| GET |
/api/v1/scenarios |
List scenarios |
| GET |
/api/v1/scenarios/{id} |
Get scenario |
| POST |
/api/v1/scenarios/{id}/query |
Execute query |
Chat¶
| Method |
Endpoint |
Description |
| POST |
/api/v1/chat |
Send message |
| POST |
/api/v1/chat/stream |
Stream response |
| GET |
/api/v1/chat/history |
Get history |
Query¶
| Method |
Endpoint |
Description |
| POST |
/api/v1/query/execute |
Execute query |
| POST |
/api/v1/query/cpgql |
Execute CPGQL |
Review¶
| Method |
Endpoint |
Description |
| POST |
/api/v1/review/patch |
Review patch |
| POST |
/api/v1/review/pr |
Review PR |
Documentation Generation¶
| Method |
Endpoint |
Description |
| POST |
/api/v1/documentation/generate |
Generate full documentation |
| POST |
/api/v1/documentation/generate/{section} |
Generate single section |
| GET |
/api/v1/documentation/stats |
Get ChromaDB stats |
| POST |
/api/v1/documentation/search |
Semantic search in docs |
WebSocket¶
| Endpoint |
Description |
/api/v1/ws/chat |
Real-time chat |
/api/v1/ws/jobs/{id} |
Job progress |
Interactive Documentation¶
After starting the server:
- Swagger UI: http://localhost:8000/api/docs
- ReDoc: http://localhost:8000/api/redoc