Skip to main content

Analysis API

Endpoints for code analysis and AI-powered insights.

Search code using natural language.

POST /v1/projects/:id/search

Request Body:

{
"query": "user authentication flow",
"limit": 10
}

Response:

{
"success": true,
"results": [
{
"filePath": "src/auth/login.ts",
"lineStart": 45,
"lineEnd": 78,
"content": "async function authenticate(email, password) {...}",
"score": 0.92,
"context": "LoginService - handles user authentication"
}
]
}

Ask AI Assistant

Ask questions about your codebase.

POST /v1/projects/:id/ask

Request Body:

{
"question": "How does the authentication system work?",
"language": "en"
}

Response:

{
"success": true,
"answer": "The authentication system uses JWT tokens...",
"references": [
{
"filePath": "src/auth/login.ts",
"description": "Main authentication logic"
}
]
}

Impact Analysis

Analyze the impact of changes to a file.

POST /v1/projects/:id/analyze

Request Body:

{
"path": "src/services/user.ts"
}

Response:

{
"success": true,
"impact": {
"directDependencies": [
"src/utils/crypto.ts",
"src/db/models/user.ts"
],
"dependents": [
"src/controllers/auth.ts",
"src/controllers/profile.ts"
],
"affectedTests": [
"tests/user.test.ts"
],
"riskLevel": "medium",
"recommendation": "Changes require testing auth and profile flows"
}
}

Code Metrics

Get code quality metrics.

GET /v1/projects/:id/metrics

Query Parameters:

ParameterTypeDescription
pathstringFilter by path (optional)

Response:

{
"success": true,
"metrics": {
"summary": {
"totalFiles": 234,
"totalLines": 15420,
"avgComplexity": 4.2,
"maxComplexity": 18,
"duplicatePercentage": 3.1
},
"byFile": [
{
"path": "src/services/complex.ts",
"lines": 450,
"complexity": 18,
"maintainability": 62
}
]
}
}

Security Scan

Get security vulnerability scan results.

GET /v1/projects/:id/security

Response:

{
"success": true,
"scan": {
"status": "completed",
"scannedAt": "2024-01-15T10:30:00Z",
"summary": {
"high": 2,
"medium": 5,
"low": 8
},
"issues": [
{
"severity": "high",
"type": "sql-injection",
"file": "src/db/query.ts",
"line": 34,
"description": "Potential SQL injection vulnerability",
"recommendation": "Use parameterized queries"
}
]
}
}

Dead Code Detection

Find unused code.

GET /v1/projects/:id/dead-code

Response:

{
"success": true,
"deadCode": {
"unusedExports": [
{
"file": "src/utils/helpers.ts",
"name": "formatDate",
"line": 45,
"type": "function"
}
],
"unusedFiles": [
"src/legacy/old-service.ts"
],
"estimatedLines": 234
}
}

Code Duplication

Find duplicated code blocks.

GET /v1/projects/:id/duplication

Response:

{
"success": true,
"duplication": {
"percentage": 3.1,
"duplicates": [
{
"lines": 15,
"occurrences": [
{ "file": "src/api/users.ts", "start": 45, "end": 60 },
{ "file": "src/api/products.ts", "start": 32, "end": 47 }
]
}
]
}
}