Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7BsvgDataUrl%7D?q=api&page=3&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=api

Returns an array of strings in format "username" or "username/projectName"

Found 18960 results for "api"(2249ms)

val-town-http-mcp-serverfileTools.ts30 matches

@nbbaier•Updated 9 hours ago
1import {McpServer} from "npm:@modelcontextprotocol/sdk/server/mcp.js"
2import {Config} from "../lib/types.ts"
3import {callValTownApi} from "../lib/api.ts"
4import {getErrorMessage} from "../lib/errorUtils.ts"
5import {getCliAvailability, runVtCommand, parseCliJsonOutput, prepareValWorkspace, cleanupTempDirectory} from "../lib/vtCli.ts"
122 console.error(`Failed to checkout branch: ${checkoutResult.error}`)
123 await cleanupTempDirectory(workspace.workspacePath!)
124 // Fall back to API
125 console.error("CLI error when checking out branch, falling back to API")
126 throw new Error("Failed to checkout branch")
127 }
147 }
148
149 console.error(`CLI error when listing files, falling back to API: ${workspace.error || "Unknown error"}`)
150 // Fall back to API on error
151 } catch (error) {
152 console.error("CLI error, falling back to API:", getErrorMessage(error))
153 // Fall back to API on error
154 }
155 }
156
157 // API implementation (original code)
158 try {
159 let queryParams = `?path=${encodeURIComponent(path)}&recursive=${recursive}&limit=${limit}&offset=${offset}`
162 }
163
164 const data = await callValTownApi(
165 config,
166 `/v2/vals/${valId}/files${queryParams}`
197
198 const response = await fetch(
199 `${config.apiBase}/v2/vals/${valId}/files/content${queryParams}`,
200 {
201 headers: {
202 'Authorization': `Bearer ${config.apiToken}`,
203 },
204 }
207 if (!response.ok) {
208 const errorText = await response.text()
209 throw new Error(`API error (${response.status}): ${errorText}`)
210 }
211
295 }
296 } else {
297 console.error(`CLI error when creating ${type}, falling back to API: ${result.error}`)
298 // Fall back to API
299 }
300 } catch (error) {
301 console.error("CLI error, falling back to API:", getErrorMessage(error))
302 // Fall back to API on error
303 }
304 }
305
306 // API implementation (original code)
307 try {
308 let queryParams = `?path=${encodeURIComponent(filePath)}`
316 }
317
318 const data = await callValTownApi(
319 config,
320 `/v2/vals/${valId}/files${queryParams}`,
384 }
385 } else {
386 console.error(`CLI error when updating file, falling back to API: ${result.error}`)
387 // Fall back to API
388 }
389 } catch (error) {
390 console.error("CLI error, falling back to API:", getErrorMessage(error))
391 // Fall back to API on error
392 }
393 }
394
395 // API implementation (original code)
396 try {
397 let queryParams = `?path=${encodeURIComponent(filePath)}`
400 }
401
402 const data = await callValTownApi(
403 config,
404 `/v2/vals/${valId}/files${queryParams}`,
488 }
489 } else {
490 console.error(`CLI error when deleting path, falling back to API: ${result.error}`)
491 // Fall back to API
492 }
493 } catch (error) {
494 console.error("CLI error, falling back to API:", getErrorMessage(error))
495 // Fall back to API on error
496 }
497 }
498
499 // API implementation (original code)
500 try {
501 let queryParams = `?path=${encodeURIComponent(filePath)}&recursive=${recursive}`
504 }
505
506 await callValTownApi(
507 config,
508 `/v2/vals/${valId}/files${queryParams}`,

val-town-http-mcp-server.env.example2 matches

@nbbaier•Updated 9 hours ago
1# Val Town API token - get from https://www.val.town/settings
2VAL_TOWN_API_TOKEN=your_api_token_here
3

val-town-http-mcp-serverconfig.ts7 matches

@nbbaier•Updated 9 hours ago
6 // For remote: expect token in request headers, use local prompt file
7 return {
8 apiToken: null, // Will be set from headers
9 apiBase: "https://api.val.town",
10 cli: {
11 preferCli: false,
22 dotenvConfig({ export: true });
23
24 const API_TOKEN = Deno.env.get("VAL_TOWN_API_TOKEN");
25 if (!API_TOKEN) {
26 console.error("Error: VAL_TOWN_API_TOKEN environment variable is required");
27 Deno.exit(1);
28 }
46 : undefined;
47 return {
48 apiToken: API_TOKEN,
49 apiBase: "https://api.val.town",
50 cli: {
51 preferCli: PREFER_CLI,

val-town-http-mcp-serverCLAUDE.md1 match

@nbbaier•Updated 9 hours ago
20- Feature branches: `feature/description`, bug fixes: `fix/description`
21- Validate all user inputs and follow least privilege principle
22- Never commit API tokens or secrets
23- Each tool should have a clear purpose with descriptive parameters

val-town-http-mcp-serverbranchTools.ts22 matches

@nbbaier•Updated 9 hours ago
1import {McpServer} from "npm:@modelcontextprotocol/sdk/server/mcp.js"
2import {Config} from "../lib/types.ts"
3import {callValTownApi} from "../lib/api.ts"
4import {getErrorMessage} from "../lib/errorUtils.ts"
5import {getCliAvailability, runVtCommand, parseCliJsonOutput, prepareValWorkspace, cleanupTempDirectory} from "../lib/vtCli.ts"
48 }
49
50 console.error(`CLI error when listing branches, falling back to API: ${workspace.error || "Unknown error"}`);
51 // Fall back to API on error
52 } catch (error) {
53 console.error("CLI error, falling back to API:", getErrorMessage(error));
54 // Fall back to API on error
55 }
56 }
57
58 // API implementation (original code)
59 try {
60 const data = await callValTownApi(
61 config,
62 `/v2/vals/${valId}/branches?limit=${limit}&offset=${offset}`
85 async ({valId, branchId}) => {
86 try {
87 const data = await callValTownApi(
88 config,
89 `/v2/vals/${valId}/branches/${branchId}`
132 console.error(`Failed to checkout source branch: ${checkoutResult.error}`);
133 await cleanupTempDirectory(workspace.workspacePath);
134 // Fall back to API
135 console.error("CLI error when checking out source branch, falling back to API");
136 throw new Error("Failed to checkout source branch");
137 }
155 }
156
157 console.error(`CLI error when creating branch, falling back to API: ${workspace.error || "Unknown error"}`);
158 // Fall back to API on error
159 } catch (error) {
160 console.error("CLI error, falling back to API:", getErrorMessage(error));
161 // Fall back to API on error
162 }
163 }
164
165 // API implementation (original code)
166 try {
167 const requestBody = {
170 }
171
172 const data = await callValTownApi(
173 config,
174 `/v2/vals/${valId}/branches`,
227 }
228
229 console.error(`CLI error when deleting branch, falling back to API: ${workspace.error || "Unknown error"}`);
230 // Fall back to API on error
231 } catch (error) {
232 console.error("CLI error, falling back to API:", getErrorMessage(error));
233 // Fall back to API on error
234 }
235 }
236
237 // API implementation (original code)
238 try {
239 await callValTownApi(
240 config,
241 `/v2/vals/${valId}/branches/${branchId}`,

val-town-http-mcp-serverblobTools.ts9 matches

@nbbaier•Updated 9 hours ago
2import {z} from "npm:zod"
3import {Config} from "../lib/types.ts"
4import {callValTownApi} from "../lib/api.ts"
5import {getErrorMessage} from "../lib/errorUtils.ts"
6
16 try {
17 const queryParams = prefix ? `?prefix=${encodeURIComponent(prefix)}` : ""
18 const data = await callValTownApi(config, `/v1/blob${queryParams}`)
19
20 return {
41 try {
42 // For blobs, we need to handle binary data differently
43 const url = `${config.apiBase}/v1/blob/${encodeURIComponent(key)}`
44 const response = await fetch(url, {
45 headers: {
46 "Authorization": `Bearer ${config.apiToken}`,
47 },
48 })
50 if (!response.ok) {
51 const errorText = await response.text()
52 throw new Error(`API request failed: ${response.status} ${response.statusText}\n${errorText}`)
53 }
54
109 }
110
111 const url = `${config.apiBase}/v1/blob/${encodeURIComponent(key)}`
112 const response = await fetch(url, {
113 method: "POST",
114 headers: {
115 "Authorization": `Bearer ${config.apiToken}`,
116 "Content-Type": contentType,
117 },
121 if (!response.ok) {
122 const errorText = await response.text()
123 throw new Error(`API request failed: ${response.status} ${response.statusText}\n${errorText}`)
124 }
125
146 async ({key}: {key: string}) => {
147 try {
148 await callValTownApi(config, `/v1/blob/${encodeURIComponent(key)}`, {
149 method: "DELETE",
150 })

val-town-http-mcp-serverapi.ts11 matches

@nbbaier•Updated 9 hours ago
1import {Config} from "./types.ts"
2
3export async function callValTownApi(
4 config: Config,
5 path: string,
7): Promise<any> {
8 // Path conversion for endpoints that have changed in v2
9 let apiPath = path
10
11 // If any old v1 paths are accidentally used, convert them to v2
12 if (path.startsWith("/v1/projects")) {
13 apiPath = path.replace("/v1/projects", "/v2/vals")
14 console.warn(`Converting deprecated v1 path to v2: ${path} → ${apiPath}`)
15 } else if (path.startsWith("/v1/alias/projects")) {
16 apiPath = path.replace("/v1/alias/projects", "/v2/alias/vals")
17 console.warn(`Converting deprecated v1 path to v2: ${path} → ${apiPath}`)
18 }
19
20 const url = `${config.apiBase}${apiPath}`
21
22 if (!config.apiToken) {
23 throw new Error("API token is required for ValTown API calls");
24 }
25
26 const headers: HeadersInit = {
27 'Authorization': `Bearer ${config.apiToken}`,
28 'Content-Type': 'application/json',
29 }
39 if (!response.ok) {
40 const errorText = await response.text()
41 throw new Error(`API error (${response.status}): ${errorText}`)
42 }
43

twilioWebhookmain.tsx3 matches

@Dentalabcs•Updated 9 hours ago
52 });
53
54 // Send the SMS via Twilio API
55 const twilioResponse = await fetch(
56 `https://api.twilio.com/2010-04-01/Accounts/${sid}/Messages.json`,
57 {
58 method: "POST",
67 if (!twilioResponse.ok) {
68 const errorText = await twilioResponse.text();
69 console.error("Twilio API error:", twilioResponse.status, errorText);
70 return new Response(`Twilio error: ${errorText}`, { status: 500 });
71 }

sqliteExplorerAppmain.tsx2 matches

@arfan•Updated 9 hours ago
27 <head>
28 <title>SQLite Explorer</title>
29 <link rel="preconnect" href="https://fonts.googleapis.com" />
30
31 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32 <link
33 href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34 rel="stylesheet"
35 />

sqliteExplorerAppREADME.md1 match

@arfan•Updated 9 hours ago
13## Authentication
14
15Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
16
17## Todos / Plans

beeminder-api4 file matches

@cricks_unmixed4u•Updated 16 hours ago

shippingAPI1 file match

@dynamic_silver•Updated 1 day ago
apiry
snartapi