Skip to main content

Overview

Retrieves the hierarchical tree structure of files and folders in the drive. Items are returned as nested nodes with their children, up to a configurable depth. This is the primary endpoint for building a file explorer or navigation sidebar.

Query Parameters

  • parentId (optional): Start the tree from this folder ID. Omit to get root-level items.
  • depth (optional): Maximum nesting depth, 1-10. Defaults to 3.

Response

Returns a tree structure with:
  • root: Array of top-level tree nodes, each with nested children
  • totalItems: Total number of items in the response
  • truncated: Whether the result was truncated (max 500 items)
  • nextParentIds: When truncated, IDs of leaf folders that have more children — use these as parentId to continue fetching
Each tree node includes:
  • id: The file or folder ID
  • name: Display name
  • type: Either file or folder
  • children: Array of nested child nodes
  • hasChildren: Boolean indicating whether this node has children beyond what was returned (useful for lazy loading)

Lazy Loading

For large drive structures, use parentId and depth together for lazy loading:
  1. Fetch the root tree with a shallow depth (e.g., depth=2)
  2. When a user expands a folder, fetch its subtree using parentId={folderId}&depth=2
  3. Use the hasChildren flag to show expand indicators in the UI