POST
/
symbol
/
find-definition
curl --request POST \
  --url http://localhost:4444/v1/symbol/find-definition \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "include_raw_response": false,
  "include_source_code": false,
  "position": {
    "path": "src/main.py",
    "position": {
      "character": 5,
      "line": 10
    }
  }
}'
{
  "definitions": [
    {
      "path": "src/main.py",
      "position": {
        "character": 5,
        "line": 10
      }
    }
  ],
  "raw_response": "<any>",
  "selected_identifier": {
    "file_range": {
      "path": "src/main.py",
      "range": {
        "end": {
          "character": 5,
          "line": 10
        },
        "start": {
          "character": 5,
          "line": 10
        }
      }
    },
    "kind": "<string>",
    "name": "<string>"
  },
  "source_code_context": [
    {
      "range": {
        "path": "src/main.py",
        "range": {
          "end": {
            "character": 5,
            "line": 10
          },
          "start": {
            "character": 5,
            "line": 10
          }
        }
      },
      "source_code": "<string>"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
position
object
required

A position within a specific file in the workspace

include_raw_response
boolean

Whether to include the raw response from the langserver in the response. Defaults to false.

Example:

false

include_source_code
boolean

Whether to include the source code around the symbol's identifier in the response. Defaults to false. TODO: Implement this

Example:

false

Response

200
application/json
Definition retrieved successfully

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}].

definitions
object[]
required

A position within a specific file in the workspace

selected_identifier
object
required

The identifier that was "clicked-on" to get the definition.

source_code_context
object[] | null

The source code of symbol definitions.