Get the definition of a symbol at a specific position in a file
curl --request POST \
--url http://localhost:4444/v1/symbol/find-definition \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"position": {
"path": "src/main.py",
"position": {
"character": 5,
"line": 10
}
},
"include_raw_response": false,
"include_source_code": false
}
'import requests
url = "http://localhost:4444/v1/symbol/find-definition"
payload = {
"position": {
"path": "src/main.py",
"position": {
"character": 5,
"line": 10
}
},
"include_raw_response": False,
"include_source_code": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
position: {path: 'src/main.py', position: {character: 5, line: 10}},
include_raw_response: false,
include_source_code: false
})
};
fetch('http://localhost:4444/v1/symbol/find-definition', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "4444",
CURLOPT_URL => "http://localhost:4444/v1/symbol/find-definition",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'position' => [
'path' => 'src/main.py',
'position' => [
'character' => 5,
'line' => 10
]
],
'include_raw_response' => false,
'include_source_code' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:4444/v1/symbol/find-definition"
payload := strings.NewReader("{\n \"position\": {\n \"path\": \"src/main.py\",\n \"position\": {\n \"character\": 5,\n \"line\": 10\n }\n },\n \"include_raw_response\": false,\n \"include_source_code\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:4444/v1/symbol/find-definition")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"position\": {\n \"path\": \"src/main.py\",\n \"position\": {\n \"character\": 5,\n \"line\": 10\n }\n },\n \"include_raw_response\": false,\n \"include_source_code\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4444/v1/symbol/find-definition")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"position\": {\n \"path\": \"src/main.py\",\n \"position\": {\n \"character\": 5,\n \"line\": 10\n }\n },\n \"include_raw_response\": false,\n \"include_source_code\": false\n}"
response = http.request(request)
puts response.read_body{
"definitions": [
{
"path": "src/main.py",
"position": {
"character": 5,
"line": 10
}
}
],
"selected_identifier": {
"file_range": {
"path": "src/main.py",
"range": {
"end": {
"character": 5,
"line": 10
},
"start": {
"character": 5,
"line": 10
}
}
},
"name": "<string>",
"kind": "<string>"
},
"raw_response": "<unknown>",
"source_code_context": [
{
"range": {
"path": "src/main.py",
"range": {
"end": {
"character": 5,
"line": 10
},
"start": {
"character": 5,
"line": 10
}
}
},
"source_code": "<string>"
}
]
}symbol
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_____^^^^
POST
/
symbol
/
find-definition
Get the definition of a symbol at a specific position in a file
curl --request POST \
--url http://localhost:4444/v1/symbol/find-definition \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"position": {
"path": "src/main.py",
"position": {
"character": 5,
"line": 10
}
},
"include_raw_response": false,
"include_source_code": false
}
'import requests
url = "http://localhost:4444/v1/symbol/find-definition"
payload = {
"position": {
"path": "src/main.py",
"position": {
"character": 5,
"line": 10
}
},
"include_raw_response": False,
"include_source_code": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
position: {path: 'src/main.py', position: {character: 5, line: 10}},
include_raw_response: false,
include_source_code: false
})
};
fetch('http://localhost:4444/v1/symbol/find-definition', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "4444",
CURLOPT_URL => "http://localhost:4444/v1/symbol/find-definition",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'position' => [
'path' => 'src/main.py',
'position' => [
'character' => 5,
'line' => 10
]
],
'include_raw_response' => false,
'include_source_code' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "http://localhost:4444/v1/symbol/find-definition"
payload := strings.NewReader("{\n \"position\": {\n \"path\": \"src/main.py\",\n \"position\": {\n \"character\": 5,\n \"line\": 10\n }\n },\n \"include_raw_response\": false,\n \"include_source_code\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("http://localhost:4444/v1/symbol/find-definition")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"position\": {\n \"path\": \"src/main.py\",\n \"position\": {\n \"character\": 5,\n \"line\": 10\n }\n },\n \"include_raw_response\": false,\n \"include_source_code\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4444/v1/symbol/find-definition")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"position\": {\n \"path\": \"src/main.py\",\n \"position\": {\n \"character\": 5,\n \"line\": 10\n }\n },\n \"include_raw_response\": false,\n \"include_source_code\": false\n}"
response = http.request(request)
puts response.read_body{
"definitions": [
{
"path": "src/main.py",
"position": {
"character": 5,
"line": 10
}
}
],
"selected_identifier": {
"file_range": {
"path": "src/main.py",
"range": {
"end": {
"character": 5,
"line": 10
},
"start": {
"character": 5,
"line": 10
}
}
},
"name": "<string>",
"kind": "<string>"
},
"raw_response": "<unknown>",
"source_code_context": [
{
"range": {
"path": "src/main.py",
"range": {
"end": {
"character": 5,
"line": 10
},
"start": {
"character": 5,
"line": 10
}
}
},
"source_code": "<string>"
}
]
}Authorizations
Body
application/json
Response
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}].
The raw response from the langserver.
