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/%7Bresult.originalUrl%7D?q=api&page=4&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 25402 results for "api"(1553ms)

qbatindex.ts2 matches

@wilhelmβ€’Updated 15 hours ago
29app.get("/callback", (c) => c.json(c.req));
30
31// Add your API routes here
32// app.get("/api/data", c => c.json({ hello: "world" }));
33
34// Unwrap and rethrow Hono errors as the original error

sachersolindex.html4 matches

@yawnxyzβ€’Updated 15 hours ago
20
21 <!-- Google Fonts: thin, airy vibe -->
22 <link rel="preconnect" href="https://fonts.googleapis.com">
23 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
24 <link href="https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@100..900&display=swap" rel="stylesheet">
25
26 <!-- Tailwind + Alpine -->
246 <ul class="mt-6 space-y-2 text-slate-700">
247 <li>β€’ Goal decomposition and habit stacking</li>
248 <li>β€’ Asynchronous check‑ins and rapid feedback loops</li>
249 <li>β€’ Parent coaching for calm collaboration</li>
250 </ul>
315 };
316 try {
317 const res = await fetch('/api/email',
318 {
319 method: 'POST',

untitled-8620main.ts7 matches

@knowβ€’Updated 16 hours ago
81/**
82 * Main asynchronous process to build the prerequisite graph level-by-level.
83 * Tracks processed nodes to avoid redundant API calls and circular dependencies.
84 */
85async function buildTreeInBackground(jobId: string, rootNode: FactNode) {
136 });
137
138 // Wait for all API calls on the current level to complete.
139 await Promise.all(processingPromises);
140
171 <script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
172 <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
173 <link rel="preconnect" href="https://fonts.googleapis.com">
174 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
175 <link href="https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,600&family=Source+Sans+3:wght@400;600&display=swap" rel="stylesheet">
176<style>
177 :root {
344 const { useState, useEffect, useCallback } = React;
345
346 const API_BASE_URL = '${sourceUrl}';
347 const POLLING_INTERVAL = 2000;
348
419
420 try {
421 const response = await fetch(\`\${API_BASE_URL}/start\`, {
422 method: 'POST',
423 headers: { 'Content-Type': 'application/json' },
442 const pollJobStatus = async () => {
443 try {
444 const response = await fetch(\`\${API_BASE_URL}/status?jobId=\${jobId}\`);
445 if (!response.ok) throw new Error('Polling failed');
446
22
23The following routes are accessible without authentication:
24- `/api/health` - System health status
25
26### Protected Routes
30**User Authentication (Google OAuth via LastLogin):**
31- `/` - Main dashboard (shows user info and system status)
32- `/api/*` - API endpoints (except health)
33- `/views/*` - View routes including `/views/glimpse/:id`
34- `/glimpse/*` - Shortcut routes including `/glimpse/:id` (equivalent to `/views/glimpse/:id`)
35
36**Webhook Authentication (X-API-KEY header):**
37- `/tasks/*` - Webhook endpoints for external integrations (POST requests only)
38 - GET requests to `/tasks/*` are allowed without authentication for debug endpoints
44β”‚ β”œβ”€β”€ controllers/ # Business logic controllers
45β”‚ β”œβ”€β”€ routes/ # Route definitions and HTTP handling
46β”‚ β”‚ β”œβ”€β”€ api/ # API endpoints
47β”‚ β”‚ β”œβ”€β”€ glimpse/ # Glimpse routes (enhanced with React frontend)
48β”‚ β”‚ β”œβ”€β”€ tasks/ # Task-related routes
84
85### **Service Layer** (External Integrations)
86- Handles external API calls (Notion, databases)
87- Manages data persistence
88- Returns structured results with success/error information
122- `GET /glimpse/:id` - **Enhanced with React Frontend** - Content negotiation based on Accept header:
123 - **Browser requests** (`Accept: text/html`): Returns rich React frontend with interactive Notion content display
124 - **API requests** (`Accept: application/json`): Returns raw JSON data (same as before)
125 - **Fallback**: If HTML template fails to load, automatically serves JSON
126
159**Note:** The glimpse endpoints now provide both programmatic access (JSON) and user-friendly viewing (React frontend) from the same URL, maintaining backward compatibility while adding rich content display capabilities.
160
161### Demo API Endpoints
162
163API endpoints for accessing Notion page data with different levels of detail:
164
165- `GET /api/demo/:id/properties` - Returns page properties only
166- `GET /api/demo/:id` - Returns page properties + all blocks recursively
167- `GET /api/agent/:id` - Returns agent blob data for a specific page ID
168
169**Architecture:**
170- **Routes**: Handle HTTP concerns (parameter extraction, response formatting, status codes)
171- **Controllers**: Contain business logic (`getDemoProperties`, `getDemoFull`)
172- **Services**: Handle Notion API integration
173
174**Authentication Behavior:**
196```javascript
197// Internal call from within Val (no authentication needed)
198const response = await fetch('/api/demo/page-id/properties');
199const data = await response.json();
200
208- Filter out button properties from Notion page data
209- Return standardized JSON responses (except authentication routes which redirect or show HTML)
210- Use the same controller functions as the API endpoints for consistency
211
212### New User Registration Flow
259### Webhook Endpoints
260
261- `POST /tasks/notion-webhook` - Main webhook endpoint for Notion integrations (requires `X-API-KEY` header)
262- `POST /tasks/url` - Updates Notion page URL property with glimpse URL (requires `X-API-KEY` header)
263- `POST /tasks/assign` - Assigns agents to tasks based on Assigned property matching (requires `X-API-KEY` header)
264- `POST /tasks/test` - Test endpoint for webhook authentication (requires `X-API-KEY` header)
265- `GET /tasks/debug-webhook` - Debug endpoint to check webhook configuration
266
366- **Preserves Same-Demo Assignments**: No clearing when reassigning to the same demo
367- **Prevents Multiple Assignments**: Ensures agents are only assigned to one demo at a time
368- **Efficient**: Minimal API calls - only clears when necessary
369- **Reliable**: Handles new agents, existing agents, and reassignments correctly
370
396- **Fast Execution**: Blob scanning is faster than database queries
397- **Targeted Processing**: Only processes pages with empty agent arrays
398- **Resource Efficient**: Minimal API calls to Notion
399
400**Monitoring Output:**
416### Authentication
417
418Webhook endpoints require the `X-API-KEY` header:
419```bash
420curl -X POST https://your-val.web.val.run/tasks/test \
421 -H "X-API-KEY: your-secret-key-here"
422```
423
437- `GLANCE_INTERACTIONS_DB_ID` - Notion database ID for interactions
438- `GLANCE_AGENTS_DB_ID` - Notion database ID for agents
439- `NOTION_API_KEY` - Notion API key for database access
440- `NOTION_WEBHOOK_SECRET` - Secret key for webhook authentication
441
446### **Authorization & Security**
447- **Email-based Access Control**: Viewing analytics are only tracked when the authenticated user's email matches the page's Email property
448- **Frontend Authorization**: Email comparison happens on the frontend before any API calls are made
449- **Zero Unauthorized Calls**: Users without matching emails generate no viewing API requests
450- **Automatic Detection**: System automatically extracts emails from Notion page properties and user authentication
451
483### **Viewing Data Flow**
4841. **Authorization Check**: Frontend compares user email with page Email property
4852. **Authorized Users**: Frontend calls `/api/viewing` β†’ Blob updated β†’ **Notion synced immediately**
486 - **Session starts** (`null` β†’ `timestamp`): Updates "Session start" and "Viewing start" (first time) properties
487 - **Session stops** (`timestamp` β†’ `null`): Clears "Session start" property (preserves "Viewing start")
4893. **User continues viewing**: Frontend updates blob every 4 seconds (no Notion calls)
4904. **User leaves/session stale**: Cron detects stale session β†’ Blob updated β†’ **Notion synced immediately**
4915. **Unauthorized Users**: No API calls made, no viewing analytics tracked
492
493### **Notion Property Behavior**
533### **Frontend Integration**
534- **Email Authorization**: Compares authenticated user email with page Email property before tracking
535- **Page Visibility API**: Tracks when users switch tabs or minimize windows
536- **Periodic updates**: Calls viewing API every 4 seconds while page is active (authorized users only)
537- **Session management**: Automatic cleanup handles crashed browsers and network issues
538- **Performance**: Non-blocking API calls don't impact user experience, zero calls for unauthorized users

blob_adminmain.tsx1 match

@danfishgoldβ€’Updated 18 hours ago
20// For backwards-compatibility with the old blob-admin
21// TODO - test that more
22app.get("/api/public/:key", (c) => {
23 return blob.get("__public/" + c.req.param("key"));
24});

blob_adminREADME.md1 match

@danfishgoldβ€’Updated 18 hours ago
12[![](https://stevekrouse-button.web.val.run/Install)](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
13
14It 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).
15
16# TODO
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>NVIDIA API Client</title>
8 <style>
9 body {
121 }
122
123 .api-key-group {
124 background: #fff3cd;
125 border: 1px solid #ffeaa7;
129 }
130
131 .api-key-group label {
132 color: #856404;
133 }
137 <div class="container">
138 <div class="form-panel">
139 <h1>NVIDIA API Client</h1>
140
141 <form id="apiForm">
142 <div class="api-key-group">
143 <div class="form-group">
144 <label for="apiKey">API Key:</label>
145 <input type="password" id="apiKey" name="apiKey" placeholder="Enter your NVIDIA API key">
146 </div>
147 </div>
205 <h2>Response</h2>
206 <div id="responseContent" class="response-content">
207 Click "Send Request" to see the API response here.
208 </div>
209 </div>
231 // Load saved values
232 function loadSavedValues() {
233 // Load API key from cookie
234 const savedApiKey = getCookie('nvidia_api_key');
235 if (savedApiKey) {
236 document.getElementById('apiKey').value = savedApiKey;
237 }
238
262 // Save current form values
263 function saveCurrentValues() {
264 const form = document.getElementById('apiForm');
265 const formData = new FormData(form);
266 const params = {};
267
268 // Save API key to cookie
269 const apiKey = formData.get('apiKey');
270 if (apiKey) {
271 setCookie('nvidia_api_key', apiKey);
272 }
273
274 // Save other parameters to localStorage
275 for (const [key, value] of formData.entries()) {
276 if (key !== 'apiKey') {
277 if (key === 'messages') {
278 try {
297 }
298
299 // Make API request
300 async function makeApiRequest(requestData, apiKey) {
301 const response = await fetch('https://integrate.api.nvidia.com/v1/chat/completions', {
302 method: 'POST',
303 headers: {
304 'Authorization': \`Bearer \${apiKey}\`,
305 'Accept': 'application/json',
306 'Content-Type': 'application/json'
366
367 // Form submission handler
368 document.getElementById('apiForm').addEventListener('submit', async (e) => {
369 e.preventDefault();
370
383 // Get form data
384 const formData = new FormData(e.target);
385 const apiKey = formData.get('apiKey');
386
387 if (!apiKey) {
388 throw new Error('API Key is required');
389 }
390
405 saveCurrentValues();
406
407 // Make API request
408 const response = await makeApiRequest(requestData, apiKey);
409
410 // Handle response based on streaming

untitled-7971main.ts1 match

@ashket3β€’Updated 19 hours ago
1// Learn more: https://docs.val.town/vals/http/
2const BASE_URL = "https://api.longcat.chat/openai";
3
4export default async function (req: Request): Promise<Response> {
mcp-registry

mcp-registrymain.tsx11 matches

@cameronpakβ€’Updated 20 hours ago
421 </div>
422 <p style="text-align: start; text-wrap: balance; max-width: 65ch;">
423 An open catalog and API for publicly available MCP servers to improve
424 discoverability and implementation. This is{" "}
425 <a href="https://www.val.town/x/cameronpak/mcp-registry">
427 </a>{" "}
428 and also serves as a proxy server for the{" "}
429 <a href="/docs" target="_blank">MCP Registry API</a>
430 </p>
431 <wa-button
478 <wa-callout variant="neutral">
479 <wa-icon slot="icon" name="gear"></wa-icon>
480 <strong>The MCP Registry API is down</strong>
481 <br />
482 I am really sorry about the downtime and will improve caching when the
483 official MCP Registry's API resumes. Check back in later.
484 </wa-callout>
485 <p style="margin-top: 1rem;">
486 I imagine the registry API was either spammed or couldn't scale fast
487 enough. Not sure and I cannot speak on behalf of MCP. Please pray for
488 those working to bring it back up.
520);
521
522// Main route with full API support
523app.get("/", async (c) => {
524 try {
525 const cursor = c.req.query("cursor");
526 const limit = parseInt(c.req.query("limit") || "30"); // API default is 30
527 const search = c.req.query("search");
528 const updatedSince = c.req.query("updated_since");
530 const type = c.req.query("type");
531
532 // Build query parameters according to API spec
533 const queryParams: any = {
534 limit: Math.min(Math.max(limit, 1), 100), // API requires: β‰₯1 ≀100
535 };
536
597});
598
599// API route for server details (JSON)
600app.get("/api/servers/:id", async (c) => {
601 try {
602 const serverId = c.req.param("id");

Letterboxd_Blueskymain.ts3 matches

@Petezarusticaβ€’Updated 21 hours ago
6
7import Parser from "https://esm.sh/rss-parser@3.13.0";
8import { BskyAgent } from "https://esm.sh/@atproto/api@0.13.17";
9
10const RSS_URL = "https://letterboxd.com/petezarustica/rss/";
56 // 4) Deduplicate by checking your recent posts for the same link
57 // (avoids needing KV on Val Town)
58 const feedResp = await agent.api.app.bsky.feed.getAuthorFeed({
59 actor: did,
60 limit: 30,
77 };
78
79 await agent.api.com.atproto.repo.createRecord({
80 repo: did,
81 collection: "app.bsky.feed.post",

PixelPixelApiMonitor1 file match

@selfire1β€’Updated 9 hours ago
Regularly polls the API and messages on an error.

weatherApp1 file match

@dcm31β€’Updated 15 hours ago
A simple weather app with dropdown cities using Open-Meteo API
fapian
<("<) <(")> (>")>
Kapil01