> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diversion.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Get tree content stream

> Get file tree snapshot. Either one of workspace, branch or commit ID needs to be specified as ref ID



## OpenAPI

````yaml get /repos/{repo_id}/tree_content/{ref_id}
openapi: 3.0.3
info:
  title: Diversion Core API
  description: >-
    Definition of the Core API used to access low-level functionality of
    Diversion
  version: 0.2.0
servers:
  - url: https://api.diversion.dev/v0
    description: Base endpoint
security: []
paths:
  /repos/{repo_id}/tree_content/{ref_id}:
    get:
      tags:
        - Repository Manipulation
      summary: Get tree content stream
      description: >-
        Get file tree snapshot. Either one of workspace, branch or commit ID
        needs to be specified as ref ID
      operationId: src.handlersv2.tree_content.tree_content
      parameters:
        - $ref: '#/components/parameters/RepoParam'
        - $ref: '#/components/parameters/RefParam'
        - $ref: '#/components/parameters/OptionalPathParam'
        - $ref: '#/components/parameters/FileWalkRecurseParam'
        - $ref: '#/components/parameters/DirOffsetItemName'
        - $ref: '#/components/parameters/IncludeDeletedItemsParam'
        - $ref: '#/components/parameters/TreeItemNameQueryParam'
        - $ref: '#/components/parameters/DirsOnlyParam'
        - $ref: '#/components/parameters/UseSelectiveSyncParam'
        - $ref: '#/components/parameters/MaxDepthParam'
        - $ref: '#/components/parameters/IncludeDownloadUrlsParam'
      responses:
        '200':
          description: Stream of file tree entries
          content:
            application/x-ndjson:
              schema:
                description: A newline delimited json, each line is a FileEntry
                type: string
                format: binary
            application/json:
              schema:
                description: (not supported, kept for documentation purposes)
                type: array
                items:
                  $ref: '#/components/schemas/FileEntry'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
        default:
          $ref: '#/components/responses/Error'
      security:
        - OAuth2:
            - coreapi/write
components:
  parameters:
    RepoParam:
      in: path
      name: repo_id
      required: true
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      description: >-
        The repo ID of the repository. Repo _name_ can be used instead of the
        ID, but usage of ID for permanent linking and API requests is preferred.
    RefParam:
      in: path
      name: ref_id
      schema:
        type: string
        example: example_id
        minLength: 3
        maxLength: 128
      required: true
      description: An ID of a workspace, branch or commit.
    OptionalPathParam:
      in: query
      name: path
      schema:
        type: string
        format: path
        example: /path/to/file
      description: Optional path to an item inside the repository.
    FileWalkRecurseParam:
      in: query
      name: recurse
      schema:
        type: boolean
        default: true
      description: Specifies if to recursively iterate file tree to next directory levels
    DirOffsetItemName:
      in: query
      name: offset
      schema:
        type: string
        example: file.ext
      description: Offset item name in directory when iterating its entries (non-inclusive)
    IncludeDeletedItemsParam:
      in: query
      name: include_deleted
      schema:
        type: boolean
        default: false
      description: Should the tree contain also deleted items or omit them from response
    TreeItemNameQueryParam:
      in: query
      name: item_name_query
      schema:
        type: string
        example: abcd
        minLength: 3
        maxLength: 128
      description: >-
        A query string to test against item name, only matching items will be
        collected
    DirsOnlyParam:
      in: query
      name: dirs_only
      schema:
        type: boolean
        default: false
      description: Return only directories in the file tree walk
    UseSelectiveSyncParam:
      in: query
      name: use_selective_sync
      schema:
        type: boolean
        default: true
      description: >-
        Return the results filtered by the workspace preferences for selective
        sync
    MaxDepthParam:
      in: query
      name: max_depth
      schema:
        type: integer
        default: 1
    IncludeDownloadUrlsParam:
      in: query
      name: include_download_urls
      schema:
        type: boolean
        default: false
      description: >
        Specifies whether to include temporary download URLs in the response or
        not, defaults to false.
  schemas:
    FileEntry:
      type: object
      properties:
        path:
          type: string
          example: hello.cc
        prev_path:
          type: string
          description: Optional hint in case the item was renamed or moved
        hash:
          type: string
          example: 6fd9c4d3e03367130c3c5e296f5a6cf1e880fdfe
          description: >
            An opaque hash of the entry, defined by the backend.

            The client should store it and provide it in update requests as
            prev_hash to detect conflicts.
        prev_hash:
          type: string
          example: 327960059fb70e19eeb72ddea5b60807c4af58b7
          description: >-
            The previous hash before this change. If this differs from the
            client version's hash, then it's a conflict.
        status:
          $ref: '#/components/schemas/ObjectStatus'
        mode:
          $ref: '#/components/schemas/FileMode'
        mtime:
          type: string
          format: date-time
        blob:
          type: object
          properties:
            storage_uri:
              $ref: '#/components/schemas/StorageUri'
            storage_backend:
              $ref: '#/components/schemas/StorageBackend'
            size:
              type: integer
              format: int64
              description: Size in bytes
            sha:
              type: string
            temp_download_url:
              type: string
              description: A temporary URL to download the file
          required:
            - storage_uri
            - storage_backend
            - size
            - sha
        access_denied:
          type: boolean
          description: Whether the user has been denied access to this path.
      required:
        - path
        - status
        - mode
    ObjectStatus:
      type: integer
      enum:
        - 1
        - 2
        - 3
        - 4
      description: 'One of: 1 - INTACT, 2 - ADDED, 3 - MODIFIED, 4 - DELETED'
      x-ogen-enum-naming:
        '1': ObjectStatus_INTACT
        '2': ObjectStatus_ADDED
        '3': ObjectStatus_MODIFIED
        '4': ObjectStatus_DELETED
    FileMode:
      type: integer
      description: The file mode (as Unix mode)
      enum:
        - 16877
        - 33188
        - 33261
        - 40960
      x-ogen-enum-naming:
        '16877': FileMode_TREE
        '33188': FileMode_FILE
        '33261': FileMode_EXECUTABLE
        '40960': FileMode_SYMLINK
    StorageUri:
      type: string
      description: >-
        Coupled with storage_backend, a uri to storage location and an optional
        offset
      example: repo_id/2aae6c35c94fcfb415dbe95f408b9ce91ee846ed:128-1023
    StorageBackend:
      type: integer
      description: For internal use only
    Error:
      type: object
      properties:
        status:
          type: integer
          description: HTTP status code
        detail:
          type: string
        title:
          type: string
        type:
          type: string
      required:
        - status
        - detail
  responses:
    BadRequest:
      description: The request does not meet the required conditions
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The specified resource was not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Error:
      description: An error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    OAuth2:
      type: oauth2
      x-tokenInfoFunc: src.token_info.token_auth
      description: This API uses OAuth 2 with the implicit grant flow
      flows:
        implicit:
          authorizationUrl: https://auth.diversion.dev/oauth2/authorize
          scopes:
            coreapi/read: Operations with no possible side-effects
            coreapi/write: Modifying operations
            coreapi/admin: >-
              Organizational operations like adding a repo or changing repo
              properties

````