API Endpoints
Comprehensive documentation of RefineAI's API endpoints, including request parameters, response formats, and example usage.
Base URL
https://api.refine-ai.tech/v1All API requests should be made to this base URL, followed by the specific endpoint path.
Analysis Endpoints
POST/analyze
Analyze a codebaseRequest Parameters
{
"repository": "string", // GitHub repository URL or path to local repository
"branch": "string", // Optional: Branch to analyze (defaults to main/master)
"include": ["string"], // Optional: File patterns to include (e.g., "src/**/*.js")
"exclude": ["string"], // Optional: File patterns to exclude (e.g., "**/*.test.js")
"options": {
"performance": boolean, // Optional: Enable performance analysis (default: true)
"security": boolean, // Optional: Enable security analysis (default: true)
"quality": boolean, // Optional: Enable code quality analysis (default: true)
"depth": "string" // Optional: Analysis depth - "basic", "standard", or "deep" (default: "standard")
}
}Response
{
"analysisId": "string", // Unique identifier for this analysis
"status": "string", // "queued", "in-progress", "completed", or "failed"
"progress": number, // Analysis progress percentage (0-100)
"estimatedTime": number, // Estimated time to completion in seconds
"createdAt": "string", // ISO timestamp of when the analysis was created
"updatedAt": "string" // ISO timestamp of when the analysis was last updated
}Example Request
curl -X POST https://api.refine-ai.tech/v1/analyze \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"repository": "https://github.com/username/repo",
"branch": "main",
"include": ["src/**/*.js", "src/**/*.ts"],
"exclude": ["**/*.test.js", "**/*.spec.ts"],
"options": {
"performance": true,
"security": true,
"quality": true,
"depth": "standard"
}
}'GET/analyze/{analysisId}
Get analysis statusPath Parameters
{
"analysisId": "string" // Required: The ID of the analysis to retrieve
}Response
{
"analysisId": "string", // Unique identifier for this analysis
"status": "string", // "queued", "in-progress", "completed", or "failed"
"progress": number, // Analysis progress percentage (0-100)
"estimatedTime": number, // Estimated time to completion in seconds
"createdAt": "string", // ISO timestamp of when the analysis was created
"updatedAt": "string", // ISO timestamp of when the analysis was last updated
"results": { // Only present when status is "completed"
"summary": {
"issuesFound": number,
"criticalIssues": number,
"highIssues": number,
"mediumIssues": number,
"lowIssues": number,
"estimatedImprovements": {
"performance": string, // e.g., "30-40%"
"security": string, // e.g., "15-20%"
"quality": string // e.g., "25-35%"
}
}
},
"error": { // Only present when status is "failed"
"code": "string",
"message": "string"
}
}Example Request
curl -X GET https://api.refine-ai.tech/v1/analyze/a1b2c3d4-e5f6-7890-abcd-1234567890ab \ -H "Authorization: Bearer YOUR_API_KEY"
GET/analyze/{analysisId}/results
Get detailed analysis resultsPath Parameters
{
"analysisId": "string" // Required: The ID of the analysis to retrieve results for
}Query Parameters
{
"category": "string", // Optional: Filter results by category ("performance", "security", "quality")
"severity": "string", // Optional: Filter results by severity ("critical", "high", "medium", "low")
"limit": number, // Optional: Limit the number of results (default: 100)
"offset": number // Optional: Offset for pagination (default: 0)
}Response
{
"analysisId": "string",
"total": number,
"limit": number,
"offset": number,
"results": [
{
"id": "string",
"category": "string", // "performance", "security", or "quality"
"severity": "string", // "critical", "high", "medium", or "low"
"title": "string",
"description": "string",
"file": "string", // File path
"lineStart": number,
"lineEnd": number,
"code": "string", // The problematic code snippet
"recommendation": "string", // Recommended fix
"optimizedCode": "string", // Suggested optimized code
"impact": {
"performance": number, // Estimated performance improvement (0-100%)
"security": number, // Estimated security improvement (0-100%)
"quality": number // Estimated quality improvement (0-100%)
}
}
]
}Optimization Endpoints
POST/optimize/{analysisId}
Create optimization planPath Parameters
{
"analysisId": "string" // Required: The ID of the analysis to create an optimization plan for
}Request Parameters
{
"issues": ["string"], // Optional: Array of issue IDs to include in the optimization plan
// If not provided, all issues will be considered
"categories": ["string"], // Optional: Categories to include ("performance", "security", "quality")
"severities": ["string"], // Optional: Severities to include ("critical", "high", "medium", "low")
"strategy": "string", // Optional: Optimization strategy ("safe", "balanced", "aggressive")
// Default: "balanced"
"outputFormat": "string" // Optional: Output format ("pr", "patch", "inline")
// Default: "pr"
}Response
{
"optimizationId": "string", // Unique identifier for this optimization plan
"analysisId": "string", // The ID of the associated analysis
"status": "string", // "created", "in-progress", "completed", or "failed"
"issuesCount": number, // Number of issues included in the plan
"estimatedTime": number, // Estimated time to implement in seconds
"createdAt": "string", // ISO timestamp of when the plan was created
"strategy": "string" // The selected optimization strategy
}POST/optimize/{optimizationId}/implement
Implement optimization planPath Parameters
{
"optimizationId": "string" // Required: The ID of the optimization plan to implement
}Request Parameters
{
"targetBranch": "string", // Optional: Target branch for PR (default: "refine-ai/optimize")
"commitMessage": "string", // Optional: Custom commit message
"prTitle": "string", // Optional: Custom PR title
"prDescription": "string" // Optional: Custom PR description
}Response
{
"implementationId": "string", // Unique identifier for this implementation
"optimizationId": "string", // The ID of the associated optimization plan
"status": "string", // "queued", "in-progress", "completed", or "failed"
"progress": number, // Implementation progress percentage (0-100)
"createdAt": "string", // ISO timestamp of when the implementation was created
"updatedAt": "string", // ISO timestamp of when the implementation was last updated
"results": { // Only present when status is "completed"
"prUrl": "string", // URL to the created pull request (if outputFormat was "pr")
"patchUrl": "string", // URL to download the patch file (if outputFormat was "patch")
"changedFiles": number, // Number of files changed
"additions": number, // Number of lines added
"deletions": number // Number of lines deleted
},
"error": { // Only present when status is "failed"
"code": "string",
"message": "string"
}
}Response Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | The request was successful |
| 201 | Created | The resource was successfully created |
| 400 | Bad Request | The request was invalid or malformed |
| 401 | Unauthorized | Authentication is required or failed |
| 403 | Forbidden | You don't have permission to access this resource |
| 404 | Not Found | The requested resource was not found |
| 429 | Too Many Requests | You've exceeded the rate limit |
| 500 | Internal Server Error | An error occurred on the server |
API Reference
For a complete API reference, you can download our OpenAPI specification:
