Get symbols in a specific file (uses ast-grep)
curl --request GET \
--url http://localhost:4444/v1/symbol/definitions-in-file \
--header 'Authorization: Bearer <token>'import requests
url = "http://localhost:4444/v1/symbol/definitions-in-file"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('http://localhost:4444/v1/symbol/definitions-in-file', 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/definitions-in-file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:4444/v1/symbol/definitions-in-file"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:4444/v1/symbol/definitions-in-file")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4444/v1/symbol/definitions-in-file")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body[
{
"file_range": {
"path": "src/main.py",
"range": {
"end": {
"character": 5,
"line": 10
},
"start": {
"character": 5,
"line": 10
}
}
},
"identifier_position": {
"path": "src/main.py",
"position": {
"character": 5,
"line": 10
}
},
"kind": "class",
"name": "User"
}
]symbol
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
GET
/
symbol
/
definitions-in-file
Get symbols in a specific file (uses ast-grep)
curl --request GET \
--url http://localhost:4444/v1/symbol/definitions-in-file \
--header 'Authorization: Bearer <token>'import requests
url = "http://localhost:4444/v1/symbol/definitions-in-file"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('http://localhost:4444/v1/symbol/definitions-in-file', 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/definitions-in-file",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:4444/v1/symbol/definitions-in-file"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:4444/v1/symbol/definitions-in-file")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:4444/v1/symbol/definitions-in-file")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body[
{
"file_range": {
"path": "src/main.py",
"range": {
"end": {
"character": 5,
"line": 10
},
"start": {
"character": 5,
"line": 10
}
}
},
"identifier_position": {
"path": "src/main.py",
"position": {
"character": 5,
"line": 10
}
},
"kind": "class",
"name": "User"
}
]Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
The path to the file to get the symbols for, relative to the root of the workspace.
Response
Symbols retrieved successfully
The full range of the symbol.
Show child attributes
Show child attributes
The start position of the symbol's identifier.
Show child attributes
Show child attributes
The kind of the symbol (e.g., function, class).
Example:
"class"
The name of the symbol.
Example:
"User"
