> ## 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.

# Get the definition of a symbol at a specific position in a file

> Returns the location of the definition for the symbol at the given position.

The input position should point inside the symbol's identifier, e.g.

The returned position points to the identifier of the symbol, and the file_path from workspace root

e.g. for the definition of `User` on line 5 of `src/main.py` with the code:
```
0: class User:
output___^
1:     def __init__(self, name, age):
2:         self.name = name
3:         self.age = age
4:
5: user = User("John", 30)
input_____^^^^
```



## OpenAPI

````yaml openapi.json post /symbol/find-definition
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:
  /symbol/find-definition:
    post:
      tags:
        - symbol
      summary: Get the definition of a symbol at a specific position in a file
      description: >-
        Returns the location of the definition for the symbol at the given
        position.


        The input position should point inside the symbol's identifier, e.g.


        The returned position points to the identifier of the symbol, and the
        file_path from workspace root


        e.g. for the definition of `User` on line 5 of `src/main.py` with the
        code:

        ```

        0: class User:

        output___^

        1:     def __init__(self, name, age):

        2:         self.name = name

        3:         self.age = age

        4:

        5: user = User("John", 30)

        input_____^^^^

        ```
      operationId: find_definition
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetDefinitionRequest'
        required: true
      responses:
        '200':
          description: Definition retrieved successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DefinitionResponse'
        '400':
          description: Bad request
        '500':
          description: Internal server error
components:
  schemas:
    GetDefinitionRequest:
      type: object
      required:
        - position
      properties:
        include_raw_response:
          type: boolean
          description: >-
            Whether to include the raw response from the langserver in the
            response.

            Defaults to false.
          example: false
        include_source_code:
          type: boolean
          description: >-
            Whether to include the source code around the symbol's identifier in
            the response.

            Defaults to false.

            TODO: Implement this
          example: false
        position:
          $ref: '#/components/schemas/FilePosition'
    DefinitionResponse:
      type: object
      description: >-
        Response to a definition request.


        The definition(s) of the symbol.

        Points to the start position of the symbol's identifier.


        e.g. for the definition of `User` on line 5 of `src/main.py` with the
        code:

        ```

        0: class User:

        _________^

        1:     def __init__(self, name, age):

        2:         self.name = name

        3:         self.age = age

        4:

        5: user = User("John", 30)

        __________^

        ```

        The definition(s) will be `[{"path": "src/main.py", "line": 0,
        "character": 6}]`.
      required:
        - definitions
        - selected_identifier
      properties:
        definitions:
          type: array
          items:
            $ref: '#/components/schemas/FilePosition'
        raw_response:
          description: >-
            The raw response from the langserver.


            https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_definition
        selected_identifier:
          $ref: '#/components/schemas/Identifier'
          description: The identifier that was "clicked-on" to get the definition.
        source_code_context:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/CodeContext'
          description: The source code of symbol definitions.
    FilePosition:
      type: object
      description: A position within a specific file in the workspace
      required:
        - path
        - position
      properties:
        path:
          type: string
          description: Path to the file, relative to the workspace root
          example: src/main.py
        position:
          $ref: '#/components/schemas/Position'
          description: Position within the file
    Identifier:
      type: object
      required:
        - name
        - file_range
      properties:
        file_range:
          $ref: '#/components/schemas/FileRange'
        kind:
          type:
            - string
            - 'null'
        name:
          type: string
    CodeContext:
      type: object
      required:
        - range
        - source_code
      properties:
        range:
          $ref: '#/components/schemas/FileRange'
        source_code:
          type: string
    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
    FileRange:
      type: object
      description: A range within a specific file, defined by start and end positions
      required:
        - path
        - range
      properties:
        path:
          type: string
          description: The path to the file.
          example: src/main.py
        range:
          $ref: '#/components/schemas/Range'
          description: The range within the file
    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.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````