> ## 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 symbols in a specific file (uses ast-grep)

> Returns a list of symbols (functions, classes, variables, etc.) defined in the specified file.

Only the variabels defined at the file level are included.

The returned positions point to the start of the symbol's identifier.

e.g. for `User` on line 0 of `src/main.py`:
```
0: class User:
_________^
1:     def __init__(self, name, age):
2:         self.name = name
3:         self.age = age
```



## OpenAPI

````yaml openapi.json get /symbol/definitions-in-file
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/definitions-in-file:
    get:
      tags:
        - symbol
      summary: Get symbols in a specific file (uses ast-grep)
      description: >-
        Returns a list of symbols (functions, classes, variables, etc.) defined
        in the specified file.


        Only the variabels defined at the file level are included.


        The returned positions point to the start of the symbol's identifier.


        e.g. for `User` on line 0 of `src/main.py`:

        ```

        0: class User:

        _________^

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

        2:         self.name = name

        3:         self.age = age

        ```
      operationId: definitions_in_file
      parameters:
        - name: file_path
          in: query
          description: >-
            The path to the file to get the symbols for, relative to the root of
            the workspace.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Symbols retrieved successfully
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Symbol'
        '400':
          description: Bad request
        '500':
          description: Internal server error
components:
  schemas:
    Symbol:
      type: object
      required:
        - name
        - kind
        - identifier_position
        - file_range
      properties:
        file_range:
          $ref: '#/components/schemas/FileRange'
          description: The full range of the symbol.
        identifier_position:
          $ref: '#/components/schemas/FilePosition'
          description: The start position of the symbol's identifier.
        kind:
          type: string
          description: The kind of the symbol (e.g., function, class).
          example: class
        name:
          type: string
          description: The name of the symbol.
          example: User
    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
    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
    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

````