API Reference
Complete REST API documentation with all endpoints, parameters, and response formats.
Base URL
https://api.greencode.ai/v1Authentication
All API requests require authentication using a Bearer token. Include your token in the request header:
Authorization: Bearer YOUR_ACCESS_TOKENGET
/repositoriesList Repositories
List all repositories for the authenticated user
Response
{
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "my-project",
"full_name": "org/my-project",
"provider": "github",
"default_branch": "main",
"last_scan_at": "2024-01-15T10:30:00Z"
}
],
"total": 25
}POST
/scansStart Scan
Start a new AI-powered security and quality scan
Request Body
{
"repository_id": "550e8400-e29b-41d4-a716-446655440000",
"scan_type": "full",
"branch": "main"
}Response
{
"id": "scan_abc123",
"status": "running",
"repository_id": "550e8400-e29b-41d4-a716-446655440000",
"scan_type": "full",
"started_at": "2024-01-15T10:30:00Z"
}GET
/scans/:idGet Scan Details
Retrieve scan status and results
Response
{
"id": "scan_abc123",
"status": "completed",
"issues_found": 12,
"security_issues": 3,
"quality_issues": 9,
"duration_seconds": 45,
"completed_at": "2024-01-15T10:30:45Z"
}GET
/scans/:id/issuesList Issues
List all issues found in a scan
Response
{
"data": [
{
"id": "issue_xyz789",
"severity": "high",
"category": "security",
"title": "SQL Injection Vulnerability",
"file_path": "src/db/queries.py",
"line": 42,
"suggested_fix": "..."
}
],
"total": 12
}POST
/issues/:id/fixApply Fix
Apply AI-generated fix for an issue
Request Body
{
"create_pull_request": true,
"branch": "fix/security-issue"
}Response
{
"success": true,
"pull_request_url": "https://github.com/org/repo/pull/123",
"fixed_at": "2024-01-15T10:35:00Z"
}