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=7&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 18990 results for "api"(4857ms)

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

@nbbaier•Updated 18 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 18 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 18 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 18 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

sqlite_adminREADME.md1 match

@arfan•Updated 19 hours ago
9To use it on your own Val Town SQLite database, [fork it](https://www.val.town/v/stevekrouse/sqlite_admin/fork) to your account.
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
12
13Migrated from folder: utils/sqlite_admin/sqlite_admin

tanstackReactHonoExampleindex.ts3 matches

@neverstew•Updated 19 hours ago
18app.get("/shared/**/*", (c) => serveFile(c.req.path, import.meta.url));
19
20// API endpoints
21app.get("/api/messages", async (c) => {
22 const messages = await getMessages();
23 return c.json(messages);
24});
25
26app.post("/api/messages", async (c) => {
27 const { content } = await c.req.json();
28

tanstackReactHonoExampleREADME.md3 matches

@neverstew•Updated 19 hours ago
38```
39
40## API Endpoints
41
42- `GET /` - Serves the React application with initial data
43- `GET /api/messages` - Fetch all messages (JSON)
44- `POST /api/messages` - Create a new message
45- `GET /public/**` - Static assets (CSS, JS, etc.)
46- `/*` - All other routes handled by TanStack Router

tanstackReactHonoExampleREADME.md5 matches

@neverstew•Updated 19 hours ago
8## Hono
9
10This app uses [Hono](https://hono.dev/) as the API framework. You can think of Hono as a replacement for [ExpressJS](https://expressjs.com/) that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like [Flask](https://github.com/pallets/flask) or [Sinatra](https://github.com/sinatra/sinatra), respectively.
11
12## Serving assets to the frontend
20### `index.html`
21
22The most complicated part of this backend API is serving index.html. In this app (like most apps) we serve it at the root, ie `GET /`.
23
24We *bootstrap* `index.html` with some initial data from the server, so that it gets dynamically injected JSON data without having to make another round-trip request to the server to get that data on the frontend. This is a common pattern for client-side rendered apps.
25
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors
31
32Hono and other API frameworks have a habit of swallowing up Errors. We turn off this default behavior by re-throwing errors, because we think most of the time you'll want to see the full stack trace instead of merely "Internal Server Error". You can customize how you want errors to appear.

tanstackReactHonoExamplequeries.ts2 matches

@neverstew•Updated 19 hours ago
7 queryKey: ["messages"],
8 queryFn: async () => {
9 const response = await fetch("/api/messages");
10 if (!response.ok) {
11 throw new Error("Failed to fetch messages");
25 return useMutation({
26 mutationFn: async (content: string) => {
27 const response = await fetch("/api/messages", {
28 method: "POST",
29 headers: { "Content-Type": "application/json" },

ChatHTMLRenderer.tsx23 matches

@c15r•Updated 19 hours ago
9}
10
11interface MCPContextAPI {
12 // Tool operations
13 listTools: () => Promise<any[]>;
37 * - Renders HTML in a secure iframe
38 * - Provides fullscreen enter/exit affordances
39 * - Exposes MCP context API to iframe content
40 * - Handles iframe communication via postMessage
41 */
46 const [isLoading, setIsLoading] = useState(true);
47
48 // Create MCP context API that will be exposed to iframe
49 const createMCPContext = useCallback((): MCPContextAPI => {
50 const findClientByName = (serverName: string) => {
51 console.log("[MCP/Browser Renderer] Finding client by name:", serverName, mcpClients);
210 const { type, id, method, args } = event.data;
211
212 if (type !== "mcp-api-call") {
213 return;
214 }
219
220 if (typeof methodFunc !== "function") {
221 throw new Error(`Unknown MCP API method: ${method}`);
222 }
223
225
226 iframe.contentWindow?.postMessage({
227 type: "mcp-api-response",
228 id,
229 success: true,
232 } catch (error) {
233 iframe.contentWindow?.postMessage({
234 type: "mcp-api-response",
235 id,
236 success: false,
252 </script>
253 <script>
254 // MCP Context API for iframe content
255 window.mcpContext = {
256 // Async wrapper for postMessage communication
257 async callAPI(method, ...args) {
258 return new Promise((resolve, reject) => {
259 const id = Math.random().toString(36).substr(2, 9);
260
261 const handleResponse = (event) => {
262 if (event.data.type === 'mcp-api-response' && event.data.id === id) {
263 window.removeEventListener('message', handleResponse);
264 if (event.data.success) {
273
274 window.parent.postMessage({
275 type: 'mcp-api-call',
276 id,
277 method,
282 setTimeout(() => {
283 window.removeEventListener('message', handleResponse);
284 reject(new Error('MCP API call timeout'));
285 }, 30000);
286 });
288
289 // Convenience methods
290 async listTools() { return this.callAPI('listTools'); },
291 async callTool(serverName, toolName, args) { return this.callAPI('callTool', serverName, toolName, args); },
292 async listPrompts() { return this.callAPI('listPrompts'); },
293 async getPrompt(serverName, promptName, args) { return this.callAPI('getPrompt', serverName, promptName, args); },
294 async listResources() { return this.callAPI('listResources'); },
295 async readResource(serverName, uri) { return this.callAPI('readResource', serverName, uri); },
296 log(level, message, data) { this.callAPI('log', level, message, data); },
297 requestFullscreen() { this.callAPI('requestFullscreen'); },
298 exitFullscreen() { this.callAPI('exitFullscreen'); },
299 async isFullscreen() { return this.callAPI('isFullscreen'); }
300 };
301
Plantfo

Plantfo8 file matches

@Llad•Updated 4 hours ago
API for AI plant info

beeminder-api4 file matches

@cricks_unmixed4u•Updated 1 day ago
apiry
snartapi