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

Open in Claude
Open in ChatGPT

List

client.search.vals.list(ValListParams { limit, offset, query } query, RequestOptionsoptions?): PageCursorURL<BasicVal { id, author, code, 9 more } >
get/v1/search/vals

Search for vals across the platform

ParametersExpand Collapse
query: ValListParams { limit, offset, query }
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
query: string

Search query

minLength1
maxLength256
ReturnsExpand Collapse
BasicVal { id, author, code, 9 more }

A Val

id: string

This val's id

formatuuid
author: Author | null

The user who created this val

id: string
username: string | null
code: string | null

TypeScript code associated with this val

createdAt: string

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

formaturi

The URL of this val on this API

formaturi

The endpoint to retrieve this val's versions

formaturi

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

formaturi
name: string

The name of this val

privacy: "public" | "unlisted" | "private"

This resource's privacy setting. Unlisted resources do not appear on profile pages or elsewhere, but you can link to them.

Accepts one of the following:
"public"
"unlisted"
"private"
public: boolean

Whether this val is available publicly on Val Town

type: "interval" | "http" | "express" | 4 more

The type of a val. HTTP can receive web requests, Email can receive emails, Cron runs periodically, and Script can be used for libraries or one-off calculations

Accepts one of the following:
"interval"
"http"
"express"
"email"
"script"
"rpc"
"httpnext"
updatedAt: string
url: string

The URL of this resource on the Val Town website

formaturi
version: number

The version of this val, starting at zero

minimum0
import ValTown from "npm:@valtown/sdk";

const client = new ValTown();

// Automatically fetches more pages as needed.
for await (const basicVal of client.search.vals.list({ limit: 1, offset: 0, query: 'x' })) {
  console.log(basicVal.id);
}
{
  "data": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "author": {
        "id": "00000000-0000-0000-0000-000000000000",
        "username": "tmcw"
      },
      "code": "export const count = 1;",
      "createdAt": "2024-06-11T22:05:12.585Z",
      "links": {
        "module": "https://example.com",
        "self": "https://example.com",
        "versions": "https://example.com",
        "endpoint": "https://example.com"
      },
      "name": "counter",
      "privacy": "public",
      "public": true,
      "type": "script",
      "updatedAt": "2019-12-27T18:11:19.117Z",
      "url": "https://val.town/v/tmcw/counter",
      "version": 0
    }
  ],
  "links": {
    "self": "https://example.com",
    "next": "https://example.com",
    "prev": "https://example.com"
  }
}
Returns Examples
{
  "data": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "author": {
        "id": "00000000-0000-0000-0000-000000000000",
        "username": "tmcw"
      },
      "code": "export const count = 1;",
      "createdAt": "2024-06-11T22:05:12.585Z",
      "links": {
        "module": "https://example.com",
        "self": "https://example.com",
        "versions": "https://example.com",
        "endpoint": "https://example.com"
      },
      "name": "counter",
      "privacy": "public",
      "public": true,
      "type": "script",
      "updatedAt": "2019-12-27T18:11:19.117Z",
      "url": "https://val.town/v/tmcw/counter",
      "version": 0
    }
  ],
  "links": {
    "self": "https://example.com",
    "next": "https://example.com",
    "prev": "https://example.com"
  }
}