Skip to content
  • Auto
  • Light
  • Dark
Get Started
View as Markdown
Copy Markdown

Open in Claude
Open in ChatGPT

Retrieve

client.vals.files.retrieve(stringvalID, FileRetrieveParams { limit, offset, path_, 3 more } query, RequestOptionsoptions?): PageCursorURL<FileRetrieveResponse { id, links, name, 4 more } >
get/v2/vals/{val_id}/files

Get metadata for files and directories in a val. If path is an empty string, returns files at the root directory.

ParametersExpand Collapse
valID: string
query: FileRetrieveParams { limit, offset, path_, 3 more }
limit: number

Maximum items to return in each paginated response

minimum1
maximum100
offset: number

Number of items to skip in order to deliver paginated results

minimum0
path_: string

Path to a file or directory (e.g. 'dir/subdir/file.ts'). Pass in an empty string to represent the root directory.

recursive: boolean

Whether to recursively act on all files in the project

branch_id?: string

Id to query

formatuuid
version?: number

Specific branch version to query

minimum0
ReturnsExpand Collapse
FileRetrieveResponse { id, links, name, 4 more }

A File or Directory's Metadata

id: string

The id of the resource

formatuuid

The URL of this resource on Val Town

formaturi

The URL of this resource's source code as a module

formaturi

The URL of this resource on this API

formaturi

This resource's web endpoint, where it serves a website or API

formaturi
name: string
path: string
type: "directory" | "file" | "interval" | 3 more
Accepts one of the following:
"directory"
"file"
"interval"
"http"
"email"
"script"
updatedAt: string
version: number
import ValTown from "npm:@valtown/sdk";

const client = new ValTown();

// Automatically fetches more pages as needed.
for await (const fileRetrieveResponse of client.vals.files.retrieve('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
  limit: 1,
  offset: 0,
  path: 'path',
  recursive: true,
})) {
  console.log(fileRetrieveResponse.id);
}
{
  "data": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "links": {
        "html": "https://example.com",
        "module": "https://example.com",
        "self": "https://example.com",
        "endpoint": "https://example.com"
      },
      "name": "name",
      "path": "path",
      "type": "directory",
      "updatedAt": "2019-12-27T18:11:19.117Z",
      "version": 0
    }
  ],
  "links": {
    "self": "https://example.com",
    "next": "https://example.com",
    "prev": "https://example.com"
  }
}
Returns Examples
{
  "data": [
    {
      "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
      "links": {
        "html": "https://example.com",
        "module": "https://example.com",
        "self": "https://example.com",
        "endpoint": "https://example.com"
      },
      "name": "name",
      "path": "path",
      "type": "directory",
      "updatedAt": "2019-12-27T18:11:19.117Z",
      "version": 0
    }
  ],
  "links": {
    "self": "https://example.com",
    "next": "https://example.com",
    "prev": "https://example.com"
  }
}