API Endpoints
ExplainThis provides RESTful API endpoints for code explanation and analysis. All endpoints are accessible via HTTPS and require authentication.
Explain Code
Get an explanation for a piece of code
POST
/v1/explainParameters
| Name | Type | Required | Description | Default |
|---|---|---|---|---|
| code | string | Yes | The code snippet to explain | - |
| mode | string | No | Explanation mode (standard, beginner, performance, security) | standard |
| language | string | No | Programming language of the code | auto-detect |
Example Request
Request Body
{
"code": "function fibonacci(n) {\n if (n <= 1) return n;\n return fibonacci(n - 1) + fibonacci(n - 2);\n}",
"mode": "performance",
"language": "javascript"
}Example Response
Response Body
{
"explanation": "This is a recursive implementation of the Fibonacci sequence...",
"language": "javascript",
"mode": "performance",
"features": [
"recursion",
"mathematical",
"dynamic-programming-candidate"
]
}Batch Explain
Get explanations for multiple code snippets
POST
/v1/explain/batchParameters
| Name | Type | Required | Description | Default |
|---|---|---|---|---|
| snippets | array | Yes | Array of code snippets to explain | - |
| mode | string | No | Explanation mode for all snippets | standard |
File Analysis
Analyze an entire file with context
POST
/v1/analyze/fileParameters
| Name | Type | Required | Description | Default |
|---|---|---|---|---|
| file | string | Yes | Content of the file to analyze | - |
| filename | string | Yes | Name of the file (for language detection) | - |
| mode | string | No | Analysis mode | standard |
Response Codes
| Code | Description |
|---|---|
| 200 | Successful request |
| 400 | Invalid request parameters |
| 401 | Invalid or missing API key |
| 429 | Rate limit exceeded |
| 500 | Internal server error |