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/%22script.js//%22https:/cdn.jsdelivr.net/npm/@editorjs/list@latest/%22?q=api&page=1&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 25510 results for "api"(2061ms)

ReactiveNotesREADME.md1 match

@jsonโ€ขUpdated 32 mins ago
8- [theme](https://github.com/vadimdemedes/thememirror/tree/main/source/themes)
9
10## API
11
12You can access the code using the `code` property:

krazyy-cam-configmain.ts7 matches

@krazyykrunalโ€ขUpdated 54 mins ago
35 JSON.stringify({
36 iss: serviceAccount.client_email,
37 scope: "https://www.googleapis.com/auth/datastore",
38 aud: "https://oauth2.googleapis.com/token",
39 exp: now + 3600,
40 iat: now,
71
72 // ---- Exchange JWT for access token ----
73 const tokenRes = await fetch("https://oauth2.googleapis.com/token", {
74 method: "POST",
75 headers: { "Content-Type": "application/x-www-form-urlencoded" },
90 // ---- Query Firestore publicLenses ----
91 const pubDocRes = await fetch(
92 `https://firestore.googleapis.com/v1/projects/${projectId}/databases/(default)/documents/publicLenses/${id}`,
93 { headers: { Authorization: `Bearer ${access_token}` } },
94 );
106 // ---- Query Firestore private user doc ----
107 const privDocRes = await fetch(
108 `https://firestore.googleapis.com/v1/projects/${projectId}/databases/(default)/documents/users/${owner}/lenses/${id}`,
109 { headers: { Authorization: `Bearer ${access_token}` } },
110 );
116 }
117 const privDoc = await privDocRes.json();
118 const apiToken = privDoc.fields.apiToken.stringValue;
119
120 // ---- Success ----
121 return new Response(JSON.stringify({ apiToken, groupId, lensId }), {
122 headers: corsHeaders(),
123 });

Gemini-2-5-Pro-O-02main.tsx28 matches

@aibotcommanderโ€ขUpdated 59 mins ago
19 provider: "google",
20 model: "gemini-2.5-pro",
21 endpoint: "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent",
22 headers: {
23 "Content-Type": "application/json",
28 provider: "google",
29 model: "gemini-1.5-flash",
30 endpoint: "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent",
31 headers: {
32 "Content-Type": "application/json",
37 provider: "google",
38 model: "models/gemini-2.5-pro",
39 endpoint: "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent",
40 headers: {
41 "Content-Type": "application/json",
77};
78
79const POE_API_KEYS = [
80 process.env.POE_API_KEY,
81 process.env.POE_API_KEY2,
82 process.env.POE_API_KEY3,
83].filter(Boolean);
84
90
91 const providedKey = req.headers.get("Authorization")?.replace("Bearer ", "") ||
92 req.headers.get("X-API-Key") ||
93 req.headers.get("X-Bot-Access-Key");
94
96 return {
97 isValid: false,
98 error: "Missing authentication. Please provide BOT_ACCESS_KEY in Authorization header, X-API-Key header, or X-Bot-Access-Key header."
99 };
100 }
110}
111
112function createPoeClient(apiKey: string): OpenAI {
113 return new OpenAI({
114 apiKey: apiKey || "YOUR_POE_API_KEY",
115 baseURL: "https://api.poe.com/v1",
116 });
117}
127 model: string,
128 prompt: string,
129 apiKeyIndex: number,
130 taskType: string,
131 timeout: number = 15000,
133): Promise<string | null> {
134 try {
135 const apiKey = POE_API_KEYS[apiKeyIndex];
136 const poeClient = createPoeClient(apiKey);
137
138 const maxTokens = selectOptimalTokens(prompt.length, taskType);
164 return content && content.trim().length > 0 ? content : null;
165 } catch (error) {
166 console.error(`Model ${model} failed with API key ${apiKeyIndex + 1}:`, error.message);
167 return null;
168 }
184 const promises: Promise<{result: string | null, model: string, keyIndex: number}>[] = [];
185
186 for (let keyIndex = 0; keyIndex < Math.min(POE_API_KEYS.length, 2); keyIndex++) {
187 for (const model of parallelModels) {
188 promises.push(
201
202 if (successful) {
203 console.log(`Success with ${successful.value.model} (API key ${successful.value.keyIndex + 1})`);
204
205 if (isImageGeneration) {
231 console.log("Trying remaining models sequentially...");
232 for (const model of remainingModels) {
233 for (let keyIndex = 0; keyIndex < POE_API_KEYS.length; keyIndex++) {
234 const result = await callSinglePoeModel(model, prompt, keyIndex, taskType, timeout, isImageGeneration);
235 if (result) {
276}
277
278async function callGeminiApi(
279 config: ModelConfig,
280 prompt: string,
308 };
309
310 const url = `${config.endpoint}?key=${process.env.GEMINI_API_KEY}`;
311 const response = await fetch(url, {
312 method: "POST",
318 if (!response.ok) {
319 const errorText = await response.text();
320 throw new Error(`${config.model} API error: ${response.status} - ${errorText}`);
321 }
322
371
372 if (shouldUseFast) {
373 const flashResult = await callGeminiApi(GEMINI_FLASH_CONFIG, prompt, send, "Text Generation");
374 if (flashResult) return;
375 } else {
376 // For complex queries, try Gemini Pro first
377 const proResult = await callGeminiApi(GEMINI_PRO_CONFIG, prompt, send, "Text Generation");
378 if (proResult) return;
379 }
416
417 // Try fast model first for file analysis
418 const flashResult = await callGeminiApi(GEMINI_FLASH_CONFIG, analysisPrompt, send, "File Analysis");
419 if (flashResult) return;
420
447
448 // Try Gemini Pro with vision first
449 const geminiResult = await callGeminiApi(GEMINI_VISION_CONFIG, analysisPrompt, send, "Image Analysis", imageUrl);
450 if (geminiResult) return;
451
484 if (!poeResult) {
485 // Fallback to Gemini Flash for search
486 const geminiResult = await callGeminiApi(GEMINI_FLASH_CONFIG, searchPrompt, send, "Web Search");
487 if (!geminiResult) {
488 send("error", {
733 headers: {
734 "Content-Type": "application/json",
735 "WWW-Authenticate": "Bearer realm=\"Bot API\"",
736 },
737 });
Gemini-2-5-Pro-O-01

Gemini-2-5-Pro-O-01main.tsx25 matches

@aibotcommanderโ€ขUpdated 1 hour ago
17 provider: "google",
18 model: "gemini-2.5-pro",
19 endpoint: "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent",
20 headers: {
21 "Content-Type": "application/json",
26 provider: "google",
27 model: "gemini-2.0-flash-lite",
28 endpoint: "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-lite:generateContent",
29 headers: {
30 "Content-Type": "application/json",
35 provider: "google",
36 model: "models/gemini-2.5-pro",
37 endpoint: "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent",
38 headers: {
39 "Content-Type": "application/json",
78};
79
80const POE_API_KEYS = [
81 process.env.POE_API_KEY,
82 process.env.POE_API_KEY2,
83 process.env.POE_API_KEY3,
84].filter(Boolean);
85
86function createPoeClient(apiKey: string): OpenAI {
87 return new OpenAI({
88 apiKey: apiKey || "YOUR_POE_API_KEY",
89 baseURL: "https://api.poe.com/v1",
90 });
91}
99 isImageGeneration: boolean = false
100): Promise<string | null> {
101 for (let keyIndex = 0; keyIndex < POE_API_KEYS.length; keyIndex++) {
102 const apiKey = POE_API_KEYS[keyIndex];
103 const poeClient = createPoeClient(apiKey);
104
105 for (let modelIndex = 0; modelIndex < models.length; modelIndex++) {
106 const model = models[modelIndex];
107 try {
108 console.log(`Trying ${taskType} with model: ${model} (API key ${keyIndex + 1})`);
109
110 const chatPromise = poeClient.chat.completions.create({
155 }
156 } catch (error) {
157 console.error(`Model ${model} failed with API key ${keyIndex + 1}:`, error.message);
158 send("text", { text: `โณ Main model failed, trying next model...` });
159 continue;
219 };
220
221 const url = `${GEMINI_PRO_CONFIG.endpoint}?key=${process.env.GEMINI_API_KEY}`;
222 const response = await fetch(url, {
223 method: "POST",
229 if (!response.ok) {
230 const errorText = await response.text();
231 throw new Error(`Gemini 2.5 Pro API error: ${response.status} - ${errorText}`);
232 }
233
282 };
283
284 const url = `${GEMINI_VISION_CONFIG.endpoint}?key=${process.env.GEMINI_API_KEY}`;
285 const response = await fetch(url, {
286 method: "POST",
292 if (!response.ok) {
293 const errorText = await response.text();
294 throw new Error(`Vision API error: ${response.status} - ${errorText}`);
295 }
296
319): Promise<string | null> {
320 try {
321 console.log(`Trying ${taskType} with Gemini API`);
322 send("text", { text: `๐Ÿ” Processing with Gemini...` });
323
334 };
335
336 const url = `${GEMINI_FALLBACK.endpoint}?key=${process.env.GEMINI_API_KEY}`;
337 const response = await fetch(url, {
338 method: "POST",
344 if (!response.ok) {
345 const errorText = await response.text();
346 throw new Error(`Gemini API error: ${response.status} - ${errorText}`);
347 }
348
360 } catch (error) {
361 console.error("Gemini first attempt failed:", error);
362 send("text", { text: `โŒ Gemini API failed: ${error.message}` });
363 return null;
364 }
386 };
387
388 const url = `${GEMINI_FALLBACK.endpoint}?key=${process.env.GEMINI_API_KEY}`;
389 const response = await fetch(url, {
390 method: "POST",
396 if (!response.ok) {
397 const errorText = await response.text();
398 throw new Error(`Gemini API error: ${response.status} - ${errorText}`);
399 }
400

last-login-demo-1index.tsx4 matches

@stevekrouseโ€ขUpdated 1 hour ago
52 try {
53 setLoading(true);
54 const response = await fetch('/api/threads');
55 if (response.ok) {
56 const data = await response.json();
66 const fetchMessages = async (threadId: number) => {
67 try {
68 const response = await fetch(`/api/threads/${threadId}/messages`);
69 if (response.ok) {
70 const data = await response.json();
84
85 try {
86 const response = await fetch(`/api/threads/${selectedThreadId}/messages`, {
87 method: 'POST',
88 headers: {
121 try {
122 setLoading(true);
123 const response = await fetch('/api/threads', {
124 method: 'POST',
125 headers: {

last-login-demo-1README.md9 matches

@stevekrouseโ€ขUpdated 1 hour ago
15```
16โ”œโ”€โ”€ backend/
17โ”‚ โ””โ”€โ”€ index.ts # Main Hono server with API routes
18โ”œโ”€โ”€ frontend/
19โ”‚ โ”œโ”€โ”€ index.html # Main HTML template
27- โœ… Hono app with LastLogin authentication
28- โœ… SQLite schema for threads and messages
29- โœ… Basic API endpoints for threads CRUD
30- โœ… Static file serving for React frontend
31
40- โœ… Chat message display with user/assistant styling
41- โœ… Message input with textarea and send button
42- โœ… OpenAI API integration (GPT-4o-mini)
43- โœ… Real-time message updates
44- โœ… Loading states and typing indicators
45- โœ… Conversation history context
46
47## API Endpoints
48
49- `GET /` - Main React app
50- `GET /api/threads` - List user's threads
51- `POST /api/threads` - Create new thread
52- `GET /api/threads/:id/messages` - Get messages for thread
53- `POST /api/threads/:id/messages` - Send message and get AI response
54
55## Database Schema
67
68- `/debug` - Check authentication status
69- `/api/test-create-thread` - Create a test thread (when logged in)

last-login-demo-1index.ts7 matches

@stevekrouseโ€ขUpdated 1 hour ago
76});
77
78// API Routes for threads
79app.get("/api/threads", async (c) => {
80 const email = c.req.header('X-LastLogin-Email');
81 if (!email) {
92
93// Test route to create a thread
94app.get("/api/test-create-thread", async (c) => {
95 const email = c.req.header('X-LastLogin-Email');
96 if (!email) {
106 message: "Thread created",
107 threadId: result.lastInsertRowId,
108 redirect: "/api/threads"
109 });
110});
127
128// Create new thread
129app.post("/api/threads", async (c) => {
130 const email = c.req.header('X-LastLogin-Email');
131 if (!email) {
151
152// Get messages for a thread
153app.get("/api/threads/:threadId/messages", async (c) => {
154 const email = c.req.header('X-LastLogin-Email');
155 if (!email) {
178
179// Send a message and get OpenAI response
180app.post("/api/threads/:threadId/messages", async (c) => {
181 const email = c.req.header('X-LastLogin-Email');
182 if (!email) {

ReactiveNotesREADME.md1 match

@jsonโ€ขUpdated 1 hour ago
8- [theme](https://github.com/vadimdemedes/thememirror/tree/main/source/themes)
9
10## API
11
12You can access the code using the `code` property:
mcp-registry

mcp-registryREADME.md4 matches

@cameronpakโ€ขUpdated 2 hours ago
9- Val.Town & Deno
10- Hono server
11- Official MCP Registry API
12- Webawesome components and icons
13
18This project is available on [Val.Town](https://www.val.town/x/cameronpak/mcp-registry) and can be accessed at: `https://cameronpak-mcp-registry.web.val.run`
19
20## API Proxy
21
22This server acts as a proxy for the official MCP Registry API, allowing you to access registry endpoints through this server. All requests are forwarded to `https://registry.modelcontextprotocol.io`.
23
24- `GET /v0/servers` - [List Servers](https://registry.modelcontextprotocol.io/docs#/operations/list-servers)
27- `GET /v0/health` - Health check
28- `GET /v0/ping` - Ping the registry
29- `GET /docs` - Redirect to official API documentation
30
31## Additional MCP Registries

nabanhotelmain.ts2 matches

@francisnkotanyiโ€ขUpdated 2 hours ago
6<meta name="description" content="NABAN HOTEL โ€” comfortable rooms, excellent service and minutes from the new airport under construction." />
7<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
8<link rel="preconnect" href="https://fonts.googleapis.com">
9<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700;800&display=swap" rel="stylesheet">
11<style>body { font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial; }</n/style>
12<style>

PixelPixelApiMonitor1 file match

@selfire1โ€ขUpdated 18 hours ago
Regularly polls the API and messages on an error.

weatherApp1 file match

@dcm31โ€ขUpdated 1 day ago
A simple weather app with dropdown cities using Open-Meteo API
fapian
<("<) <(")> (>")>
Kapil01