> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lsproxy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Read source code from a file in the workspace

> Returns the contents of the specified file.



## OpenAPI

````yaml openapi.json post /workspace/read-source-code
openapi: 3.1.0
info:
  title: lsproxy
  description: ''
  license:
    name: Apache-2.0
    url: https://www.apache.org/licenses/LICENSE-2.0
  version: 0.2.1
servers:
  - url: http://localhost:4444/v1
    description: API server v1
security:
  - bearer_auth: []
tags:
  - name: lsproxy-api
    description: LSP Proxy API
paths:
  /workspace/read-source-code:
    post:
      tags:
        - workspace
      summary: Read source code from a file in the workspace
      description: Returns the contents of the specified file.
      operationId: read_source_code
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReadSourceCodeRequest'
        required: true
      responses:
        '200':
          description: Source code retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ReadSourceCodeResponse'
        '400':
          description: Bad request
        '500':
          description: Internal server error
components:
  schemas:
    ReadSourceCodeRequest:
      type: object
      required:
        - path
      properties:
        path:
          type: string
          description: Path to the file, relative to the workspace root
          example: src/main.py
        range:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/Range'
              description: Optional range within the file to read
    ReadSourceCodeResponse:
      type: object
      required:
        - source_code
      properties:
        source_code:
          type: string
    Range:
      type: object
      required:
        - start
        - end
      properties:
        end:
          $ref: '#/components/schemas/Position'
          description: The end position of the range.
        start:
          $ref: '#/components/schemas/Position'
          description: The start position of the range.
    Position:
      type: object
      description: A position within a text document, using 0-based indexing
      required:
        - line
        - character
      properties:
        character:
          type: integer
          format: int32
          description: 0-indexed character index within the line.
          example: 5
          minimum: 0
        line:
          type: integer
          format: int32
          description: 0-indexed line number.
          example: 10
          minimum: 0
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````