Skip to main content
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

uri
string
required
Viking URI of the directory
output
string
default:"agent"
Output format: original or agent
abs_limit
integer
default:"128"
Abstract limit (only for agent output mode)
show_all_hidden
boolean
default:"false"
List all hidden files (like ls -a)
node_limit
integer
default:"1000"
Maximum number of nodes to traverse
level_limit
integer
default:"3"
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.
name
string
File or directory name
size
integer
Size in bytes
isDir
boolean
true if directory, false if file
rel_path
string
Relative path from the base URI
uri
string
Full Viking 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