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=48&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 19574 results for "api"(4616ms)

api_ianmenethil_compackage.json2 matches

@ianmenethilUpdated 2 days ago
1{
2 "name": "modular-api-server",
3 "version": "1.0.0",
4 "description": "A modular API server with OpenAPI-driven routing",
5 "main": "main.tsx",
6 "type": "module",

reactHonoStarterindex.ts2 matches

@krishnaUpdated 2 days ago
48app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
49
50// Add your API routes here
51// app.get("/api/data", c => c.json({ hello: "world" }));
52
53// Unwrap and rethrow Hono errors as the original error

sqlite2main.tsx5 matches

@charmaineUpdated 2 days ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { LibsqlError, type TransactionMode } from "npm:@libsql/client";
3import { z } from "npm:zod";
35
36async function execute(statement: InStatement): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v2/sqlite/execute`, {
38 method: "POST",
39 headers: {
40 Authorization: `Bearer ${
41 Deno.env.get("valtown") || Deno.env.get("VAL_TOWN_API_KEY")
42 }`,
43 },
54 mode?: TransactionMode,
55): Promise<ResultSet[]> {
56 const res = await fetch(`${API_URL}/v2/sqlite/batch`, {
57 method: "POST",
58 headers: {
59 Authorization: `Bearer ${
60 Deno.env.get("valtown") || Deno.env.get("VAL_TOWN_API_KEY")
61 }`,
62 },

Louai_team_performance_review.ts46 matches

@jeffvincentUpdated 2 days ago
7 TeamPerformanceStats,
8 WaiverWirePlayer,
9 YahooFantasyAPIClient,
10} from "../daily_lineup_scheduler.tsx";
11import { LouTokenStorage } from "../token_storage.tsx";
135 review?: AITeamPerformanceReview;
136 error?: {
137 type: "AUTH_ERROR" | "API_ERROR" | "ANALYSIS_ERROR" | "VALIDATION_ERROR" | "UNKNOWN_ERROR";
138 message: string;
139 details?: any;
141 execution_stats: {
142 duration_ms: number;
143 api_calls_made: number;
144 tokens_used?: number;
145 rate_limited: boolean;
213 ): Promise<ReviewExecutionResult> {
214 const startTime = Date.now();
215 let apiCallsCounter = 0;
216 let rateLimited = false;
217
226 "No valid authentication tokens found",
227 startTime,
228 apiCallsCounter,
229 rateLimited,
230 );
231 }
232
233 // Step 2: Initialize Yahoo API client
234 const yahooAPI = new YahooFantasyAPIClient(tokenData, this.tokenStorage, userId);
235
236 // Step 3: Get team key if not provided
237 if (!teamKey) {
238 teamKey = await yahooAPI.getTeamKey(userId, leagueId);
239 apiCallsCounter++;
240
241 if (!teamKey) {
242 return this.createErrorResult(
243 "API_ERROR",
244 "Could not determine team key for user in league",
245 startTime,
246 apiCallsCounter,
247 rateLimited,
248 );
254 // Step 4: Gather comprehensive performance data
255 console.log("📊 Gathering performance data...");
256 const performanceData = await this.gatherPerformanceData(yahooAPI, teamKey, leagueId);
257 apiCallsCounter += performanceData.apiCalls;
258 rateLimited = rateLimited || performanceData.rateLimited;
259
260 if (!performanceData.success) {
261 return this.createErrorResult(
262 "API_ERROR",
263 "Failed to gather performance data",
264 startTime,
265 apiCallsCounter,
266 rateLimited,
267 performanceData.error,
277 `Data validation failed: ${validationResult.errors.join(", ")}`,
278 startTime,
279 apiCallsCounter,
280 rateLimited,
281 );
296 "Failed to generate performance analysis report",
297 startTime,
298 apiCallsCounter,
299 rateLimited,
300 );
309 "AI analysis failed",
310 startTime,
311 apiCallsCounter,
312 rateLimited,
313 aiAnalysisResult.error,
326 "Waiver analysis failed",
327 startTime,
328 apiCallsCounter,
329 rateLimited,
330 waiverAnalysisResult.error,
349 execution_stats: {
350 duration_ms: duration,
351 api_calls_made: apiCallsCounter,
352 rate_limited: rateLimited,
353 },
359 error instanceof Error ? error.message : "Unknown error occurred",
360 startTime,
361 apiCallsCounter,
362 rateLimited,
363 error,
419 results: {
420 authentication: boolean;
421 yahooAPI: boolean;
422 openAI: boolean;
423 performanceAnalyzer: boolean;
429 const results = {
430 authentication: false,
431 yahooAPI: false,
432 openAI: false,
433 performanceAnalyzer: false,
445 }
446
447 // Test 2: OpenAI API
448 try {
449 const openAITest = await this.openaiClient.testConnection();
468 }
469
470 // Test 4: Yahoo API (requires valid tokens, so just test instantiation)
471 try {
472 const testTokens = { access_token: "test", refresh_token: "test", expires_at: Date.now() + 3600000 };
473 const yahooAPI = new YahooFantasyAPIClient(testTokens, this.tokenStorage, "test_user");
474 results.yahooAPI = true; // If instantiation succeeds
475 console.log("✅ Yahoo API test passed");
476 } catch (error) {
477 errors.push(`Yahoo API test failed: ${error}`);
478 console.log("❌ Yahoo API test failed");
479 }
480
497 */
498 private async gatherPerformanceData(
499 yahooAPI: YahooFantasyAPIClient,
500 teamKey: string,
501 leagueId: string,
508 leagueContext?: any;
509 };
510 apiCalls: number;
511 rateLimited: boolean;
512 error?: any;
513 }> {
514 let apiCalls = 0;
515 let rateLimited = false;
516
517 try {
518 // Get team performance stats
519 const teamStats = await yahooAPI.getTeamPerformanceStats(teamKey, leagueId);
520 apiCalls++;
521
522 if (!teamStats) {
525
526 // Get team roster
527 const roster = await yahooAPI.getTeamRoster(teamKey);
528 apiCalls++;
529
530 // Get detailed player performance (batch process to avoid rate limits)
534 for (let i = 0; i < roster.length; i += batchSize) {
535 const batch = roster.slice(i, i + batchSize);
536 const batchPromises = batch.map(player => yahooAPI.getPlayerPerformanceStats(player.player_id, leagueId));
537
538 try {
539 const batchResults = await Promise.allSettled(batchPromises);
540 apiCalls += batch.length;
541
542 for (const result of batchResults) {
557
558 // Get waiver wire players
559 const waiverPlayers = await yahooAPI.getWaiverWirePlayers(
560 leagueId,
561 undefined, // No position filter
562 undefined, // No ownership threshold
563 );
564 apiCalls++;
565
566 // Limit waiver candidates to avoid token overflow
578 teamKey,
579 );
580 // Note: This doesn't count as additional API calls since it uses cached data
581 } catch (error) {
582 console.log("⚠️ Could not gather league context:", error);
592 leagueContext,
593 },
594 apiCalls,
595 rateLimited,
596 };
598 return {
599 success: false,
600 apiCalls,
601 rateLimited,
602 error,
832 message: string,
833 startTime: number,
834 apiCalls: number,
835 rateLimited: boolean,
836 details?: any,
841 execution_stats: {
842 duration_ms: Date.now() - startTime,
843 api_calls_made: apiCalls,
844 rate_limited: rateLimited,
845 },
15Use GlobalRateLimitedChatOpenAI(model, requestsPerSecond) to enforce a global rate limit on chat completions, suitable for shared or public-facing endpoints.
16Val Town/Platform Notes
17Uses Val Town’s standard SQLite API for persistent storage.
18Designed for server-side use (no browser-specific code).
19No secrets are hardcoded; OpenAI API keys are managed by the OpenAI SDK/environment.

sqliteExplorerApp1README.md1 match

@tmcwUpdated 2 days 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

sqliteExplorerApp1main.tsx2 matches

@tmcwUpdated 2 days 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 />

openai-client.cursorrules10 matches

@cricks_unmixed4uUpdated 2 days ago
13- Generate code in TypeScript or TSX
14- Add appropriate TypeScript types and interfaces for all data structures
15- Prefer official SDKs or libraries than writing API calls directly
16- Ask the user to supply API or library documentation if you are at all unsure about it
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
23### 1. HTTP Trigger
24
25- Create web APIs and endpoints
26- Handle HTTP requests and responses
27- Example structure:
173However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
174If you need access to this data on the client, run it in the server and pass it to the client by splicing it into the HTML page
175or by making an API request for it.
176
177## Val Town Platform Specifics
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
184- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
185- **View Source:** Add a view source link by importing & using `import.meta.url.replace("ems.sh", "val.town)"` (or passing this data to the client) and include `target="_top"` attribute
186- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
187- **Error Handling:** Only use try...catch when there's a clear local resolution; Avoid catches that merely log or return 500s. Let errors bubble up with full context
188- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
189- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
190- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
224### Backend (Hono) Best Practices
225
226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
248 });
249 ```
250- Create RESTful API routes for CRUD operations
251- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
252 ```ts
285 - For files in the project, use `readFile` helpers
286
2875. **API Design:**
288 - `fetch` handler is the entry point for HTTP vals
289 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

openai-clientknowledge.md10 matches

@cricks_unmixed4uUpdated 2 days ago
13- Generate code in TypeScript or TSX
14- Add appropriate TypeScript types and interfaces for all data structures
15- Prefer official SDKs or libraries than writing API calls directly
16- Ask the user to supply API or library documentation if you are at all unsure about it
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
23### 1. HTTP Trigger
24
25- Create web APIs and endpoints
26- Handle HTTP requests and responses
27- Example structure:
173However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
174If you need access to this data on the client, run it in the server and pass it to the client by splicing it into the HTML page
175or by making an API request for it.
176
177## Val Town Platform Specifics
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
184- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
185- **View Source:** Add a view source link by importing & using `import.meta.url.replace("ems.sh", "val.town)"` (or passing this data to the client) and include `target="_top"` attribute
186- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
187- **Error Handling:** Only use try...catch when there's a clear local resolution; Avoid catches that merely log or return 500s. Let errors bubble up with full context
188- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
189- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
190- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
224### Backend (Hono) Best Practices
225
226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
248 });
249 ```
250- Create RESTful API routes for CRUD operations
251- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
252 ```ts
285 - For files in the project, use `readFile` helpers
286
2875. **API Design:**
288 - `fetch` handler is the entry point for HTTP vals
289 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

quizMastergemini.tsx1 match

@affanUpdated 2 days ago
1import { GoogleGenAI, Type } from "npm:@google/genai";
2
3const ai = new GoogleGenAI({ apiKey: "AIzaSyDcuswpF8sAUBVTvrUlnpADXF4gHjTTAxA" });
4
5const _prompt = `Parse the image and extract the question and options, also find the answer if given otherwise return "".

researchAgent2 file matches

@thesephistUpdated 1 day ago
This is a lightweight wrapper around Perplexity's web search API

memoryApiExample2 file matches

@ingenierotitoUpdated 1 day ago
apiry
snartapi