Skip to content

API Reference

Yiğit ERDOĞAN edited this page Jan 11, 2026 · 1 revision

🛠️ API Reference

This page documents the backend API endpoints for CodeScope. All endpoints are prefixed with /api/v1 by default.

Base URL

http://localhost:8000/api/v1

Endpoints

1. System Health

Checks if the backend and its dependencies (Ollama, ChromaDB) are online.

  • URL: /health
  • Method: GET
  • Response:
    {
      "status": "healthy",
      "service": "CodeScope",
      "version": "0.1.0",
      "ollama": "connected"
    }

2. Ingest Repository

Indexes a local repository into the vector database.

  • URL: /ingest
  • Method: POST
  • Request Body:
    {
      "path": "/absolute/path/to/repo"
    }
  • Response:
    {
      "status": "success",
      "message": "Ingestion completed",
      "files_processed": 142
    }

3. Chat with Code

Send a query to the AI assistant based on the indexed codebase.

  • URL: /chat
  • Method: POST
  • Request Body:
    {
      "query": "How is authentication implemented?",
      "stream": true
    }
  • Response: Server-Sent Events (SSE) streaming the AI response.

4. Get File Tree

Retrieves the file structure of the indexed repository.

  • URL: /files/tree
  • Method: GET
  • Response: Hierarchical JSON structure of the codebase.

5. Get File Content

Retrieves the content of a specific file.

  • URL: /files/content
  • Method: GET
  • Params: path=/relative/path/to/file.py

Error Handling

The API uses standard HTTP status codes:

  • 200: Success
  • 400: Bad Request (e.g., invalid path)
  • 404: Not Found
  • 500: Internal Server Error (e.g., Ollama connection lost)

Next Steps

Clone this wiki locally