Skip to main content

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/explain

Parameters

NameTypeRequiredDescriptionDefault
codestringYesThe code snippet to explain-
modestringNoExplanation mode (standard, beginner, performance, security)standard
languagestringNoProgramming language of the codeauto-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/batch

Parameters

NameTypeRequiredDescriptionDefault
snippetsarrayYesArray of code snippets to explain-
modestringNoExplanation mode for all snippetsstandard

File Analysis

Analyze an entire file with context

POST/v1/analyze/file

Parameters

NameTypeRequiredDescriptionDefault
filestringYesContent of the file to analyze-
filenamestringYesName of the file (for language detection)-
modestringNoAnalysis modestandard

Response Codes

CodeDescription
200Successful request
400Invalid request parameters
401Invalid or missing API key
429Rate limit exceeded
500Internal server error