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/?q=api&page=6&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 12039 results for "api"(583ms)

Townieindex.ts3 matches

@devdoshiUpdated 11 hours ago
39);
40
41// token middleware for API requests
42app.all("/api/*", async (c, next) => {
43 const sessionCookie = getCookie(c, "_session");
44 if (!sessionCookie) {
50});
51
52app.route("/api", backend);
53
54app.get("/frontend/*", c => {

Townieindex.ts7 matches

@devdoshiUpdated 11 hours ago
1import { basicAuthMiddleware } from "./auth.ts";
2import { handleApiRequest } from "./api/index.ts";
3import { getRequests } from "./api/requests.ts";
4import { getUserSummary } from "./api/user-summary.ts";
5import { getInferenceCalls } from "./api/inference-calls.ts";
6import { renderDashboard } from "./views/dashboard.ts";
7import { renderRequests } from "./views/requests.ts";
22 const path = url.pathname;
23
24 // Handle API requests
25 if (path.startsWith("/api/")) {
26 return handleApiRequest(req);
27 }
28

Townieindex.ts5 matches

@devdoshiUpdated 11 hours ago
4
5/**
6 * Handle API requests
7 */
8export async function handleApiRequest(req: Request): Promise<Response> {
9 const url = new URL(req.url);
10 const path = url.pathname.replace("/api/", "");
11
12 try {
13 // Route to the appropriate API handler
14 if (path === "requests") {
15 const usageId = url.searchParams.get("usage_id");
59 }
60 } catch (error) {
61 console.error("API error:", error);
62 return new Response(JSON.stringify({ error: error.message }), {
63 status: 500,

TownieHome.tsx5 matches

@devdoshiUpdated 11 hours ago
42 </h2>
43 <ol>
44 <li>Login with your Val Town API token (with projects:read, projects:write, user:read permissions)</li>
45 <li>Select a project to work on</li>
46 <li>Chat with Claude about your code</li>
79 </div>
80 <h3>Cost Tracking</h3>
81 <p>See estimated API usage costs for each interaction</p>
82 </div>
83 </section>
92 <ul>
93 <li>React frontend with TypeScript</li>
94 <li>Hono API server backend</li>
95 <li>Web Audio API for sound notifications</li>
96 <li>AI SDK for Claude integration</li>
97 </ul>
98 <p>
99 The application proxies requests to the Anthropic API and Val Town API, allowing Claude to view and edit your
100 project files directly.
101 </p>

social_data_api_projectproxy-api.ts23 matches

@tsuchi_yaUpdated 13 hours ago
1/**
2 * SocialData API Proxy for Cloudflare Workers
3 * Acts as a backend for the X Search UI, handling API key management,
4 * and request forwarding to SocialData API.
5 *
6 * This proxy runs on Cloudflare Workers and connects to:
7 * - Supabase for authentication and user management
8 * - Cloudflare D1 for tweet storage
9 * - SocialData API for Twitter/X data
10 */
11
41 try {
42 // Supabaseの公開鍵を使ってJWTを検証するのが理想ですが、
43 // 簡易的な実装としてSupabase APIを利用して検証します
44 const supabaseUrl = env.SUPABASE_URL;
45 const supabaseKey = env.SUPABASE_SERVICE_KEY;
50 }
51
52 // Supabase Auth APIを利用してユーザー情報を取得
53 const response = await fetch(`${supabaseUrl}/auth/v1/user`, {
54 headers: {
55 "Authorization": `Bearer ${token}`,
56 "apikey": supabaseKey,
57 },
58 });
69 headers: {
70 "Authorization": `Bearer ${supabaseKey}`,
71 "apikey": supabaseKey,
72 },
73 });
104
105/**
106 * Forward request to SocialData API
107 * @param {string} query - Search query
108 * @param {string} type - Search type (Latest or Top)
113async function forwardToSocialData(query, type, cursor, env) {
114 try {
115 const apiKey = env.SOCIAL_DATA_API_KEY;
116 if (!apiKey) {
117 throw new Error("SOCIAL_DATA_API_KEY environment variable not set");
118 }
119
120 const apiUrl = new URL("https://api.socialdata.tools/twitter/search");
121 apiUrl.searchParams.set("query", query);
122 apiUrl.searchParams.set("type", type || "Latest");
123 if (cursor) {
124 apiUrl.searchParams.set("cursor", cursor);
125 }
126
127 const response = await fetch(apiUrl.toString(), {
128 headers: {
129 "Authorization": `Bearer ${apiKey}`,
130 "Accept": "application/json",
131 },
136 try {
137 const errorData = await response.json();
138 errorText = errorData.message || `API Error: ${response.statusText}`;
139 } catch {
140 errorText = `API Error: ${response.statusText}`;
141 }
142 throw new Error(errorText);
167 "Content-Type": "application/json",
168 "Authorization": `Bearer ${supabaseKey}`,
169 "apikey": supabaseKey,
170 "Prefer": "return=minimal",
171 },
344 ctx.waitUntil(incrementSearchCount(authResult.userId, env));
345
346 // Forward request to SocialData API
347 const data = await forwardToSocialData(query, type, cursor, env);
348
450 JSON.stringify({
451 status: "ok",
452 message: "SocialData API Proxy is running",
453 environment: "Cloudflare Workers",
454 }),

parallelmain.ts10 matches

@salonUpdated 13 hours ago
562 }
563
564 const apiRequestBody: any = { model, messages: messagesPayload };
565 if (typeof params.temperature === "number") apiRequestBody.temperature = params.temperature;
566 if (typeof params.max_tokens === "number" && params.max_tokens > 0)
567 apiRequestBody.max_tokens = Math.floor(params.max_tokens);
568
569 log("INFO", "OpenAiCallTool", "Making OpenAI chat completion call.", {
576
577 try {
578 const completion = await openaiClient.chat.completions.create(apiRequestBody);
579 if (!completion?.choices?.length) {
580 log("WARN", "OpenAiCallTool", "OpenAI response empty/unexpected.", { response: completion });
583 return { mandateId, correlationId: taskId, payload: { result: completion } };
584 } catch (e: any) {
585 log("ERROR", "OpenAiCallTool", "OpenAI API call failed.", e);
586 const errMsg = e.response?.data?.error?.message || e.error?.message || e.message || "Unknown OpenAI API error";
587 return { mandateId, correlationId: taskId, payload: { result: null }, error: errMsg };
588 }
701 const { mandateId, taskId, payload } = input;
702 const { log } = context;
703 log("INFO", "ScrapeEmails", `Scraping emails for ${payload.businesses?.length ?? 0} sites.`);
704
705 if (!payload?.businesses || !Array.isArray(payload.businesses)) {
753 await delay(WEBSITE_VISIT_DELAY_MS);
754 }
755 log("SUCCESS", "ScrapeEmails", `Scraping done. Found emails for ${foundLeads.length} leads.`);
756 return { mandateId, correlationId: taskId, payload: { leads: foundLeads } };
757}
810 } catch (error: any) {
811 log("ERROR", "DraftEmails", `Failed for ${lead.name}: ${error.message}`, error);
812 finalLeads.push({ ...lead, draftedEmail: "[OpenAI API call failed]" });
813 }
814 await delay(300); // Small delay between OpenAI calls
1117<body><h1>Superpowered Agent Platform - Lead Gen Demo</h1>
1118<p>Runs <code>leadGenWorkflowV1</code>. See <a href="/">Original V3 Demo</a>.</p>
1119<p><strong>Note:</strong> Google Search is simulated. Scraping is basic.</p>
1120<form id="leadGenForm">
1121 <label for="searchQuery">Search Query (Required):</label><input type="text" id="searchQuery" name="searchQuery" required value="dentists in Los Angeles">

ipv4-counterindex.ts2 matches

@maxmUpdated 16 hours ago
15await initDatabase();
16
17// API endpoint to get visit data
18app.get("/api/visits", async (c) => {
19 const visits = await getAllVisits();
20 const totalVisits = await getTotalVisits();
226
227 // Add engagement filters
228 // Always use min_ (greater than or equal to) for API filters
229 if (likesCount) {
230 finalQuery += ` min_faves:${likesCount}`;
236
237 // Note: Replies count, bookmark count, and views count might not be directly filterable
238 // in the Twitter/X API. These may need to be filtered client-side after fetching.
239
240 return finalQuery.trim();
272 maxTweets: parseInt(maxTweets),
273 filters: {
274 // These filters will be applied client-side if the API doesn't support them directly
275 // Always use "greater than or equal to" filtering
276 repliesCount: repliesCount
380 // Helper to check if a tweet meets the client-side filter criteria
381 const meetsCriteria = (tweet) => {
382 // Apply any client-side filters here that the API doesn't support
383 // Only perform "greater than or equal to" checks
384
401 }
402
403 // Apply like count filter if not handled by API
404 if (likesCount && tweet.favorite_count !== undefined) {
405 if (tweet.favorite_count < parseInt(likesCount)) return false;
406 }
407
408 // Apply retweet count filter if not handled by API
409 if (retweetsCount && tweet.retweet_count !== undefined) {
410 if (tweet.retweet_count < parseInt(retweetsCount)) return false;

StarterPackFeedsimage.tsx3 matches

@moeUpdated 19 hours ago
84
85const loadEmoji = (code) => {
86 // const api = `https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${code.toLowerCase()}.svg`
87 const api = `https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${code.toLowerCase()}_color.svg`;
88 return fetch(api).then((r) => r.text());
89};
90

ipv4-counterindex.html1 match

@maxmUpdated 20 hours ago
125 document.getElementById('refresh-btn').addEventListener('click', async () => {
126 try {
127 const response = await fetch('/api/visits');
128 const data = await response.json();
129 updateUI(data);

social_data_api_project3 file matches

@tsuchi_yaUpdated 11 hours ago

simple-scrabble-api1 file match

@bryUpdated 3 days ago
snartapi
papimark21