Get a recursive tree view of directory contents, showing the complete hierarchy.
Python SDK
from openviking import OpenViking
client = OpenViking()
# Get directory tree
entries = client.tree("viking://resources/")
for entry in entries:
type_str = "dir" if entry['isDir'] else "file"
print(f"{entry['rel_path']} - {type_str}")
HTTP API
curl -X GET "http://localhost:1933/api/v1/fs/tree?uri=viking://resources/" \
-H "X-API-Key: your-key"
GET /api/v1/fs/tree?uri=viking://resources/
Parameters
Viking URI of the directory
Output format: original or agent
Abstract limit (only for agent output mode)
List all hidden files (like ls -a)
Maximum number of nodes to traverse
Maximum depth level to traverse
Response
Returns a flat array of all entries in the tree, each with a rel_path field showing its position in the hierarchy.
true if directory, false if file
Relative path from the base URI
{
"status": "ok",
"result": [
{
"name": "docs",
"size": 4096,
"isDir": true,
"rel_path": "docs/",
"uri": "viking://resources/docs/"
},
{
"name": "api.md",
"size": 1024,
"isDir": false,
"rel_path": "docs/api.md",
"uri": "viking://resources/docs/api.md"
},
{
"name": "guides",
"size": 4096,
"isDir": true,
"rel_path": "docs/guides/",
"uri": "viking://resources/docs/guides/"
},
{
"name": "quickstart.md",
"size": 512,
"isDir": false,
"rel_path": "docs/guides/quickstart.md",
"uri": "viking://resources/docs/guides/quickstart.md"
}
],
"time": 0.2
}
CLI
openviking tree viking://resources/my-project/
Notes
- The tree is returned as a flat array, not a nested structure
- Use
rel_path to understand the hierarchy
- Default
level_limit of 3 prevents extremely deep traversals
- Use
node_limit to prevent memory issues with very large directories