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/image-url.jpg%20%22Image%20title%22?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 11547 results for "api"(1187ms)

telegramBotStartersendTelegramMessage.tsx4 matches

@asdfgUpdated 23 hours ago
1/**
2 * Sends a message to a Telegram chat via the Telegram Bot API
3 * Requires a Telegram Bot token as an environment variable
4 */
10 }
11
12 const telegramApiUrl = `https://api.telegram.org/bot${botToken}/sendMessage`;
13
14 const response = await fetch(telegramApiUrl, {
15 method: 'POST',
16 headers: {
25 if (!response.ok) {
26 const errorBody = await response.text();
27 throw new Error(`Telegram API error: ${response.status} ${errorBody}`);
28 }
29

Towniesend-message.ts6 matches

@valdottownUpdated 23 hours ago
20 }
21
22 const { messages, project, branchId, anthropicApiKey, selectedFiles, images } = await c.req.json();
23 // console.log("Original messages:", JSON.stringify(messages, null, 2));
24 // console.log("Images received:", JSON.stringify(images, null, 2));
25
26 const apiKey = anthropicApiKey || Deno.env.get("ANTHROPIC_API_KEY");
27 const our_api_token = apiKey === Deno.env.get("ANTHROPIC_API_KEY");
28
29 if (our_api_token) {
30 if (await overLimit(bearerToken)) {
31 return Response.json("You have reached the limit of Townie in a 24 hour period.", { status: 403 });
34
35 const anthropic = createAnthropic({
36 apiKey,
37 });
38
159 onFinish: async (result: any) => {
160 await trackUsage({
161 our_api_token,
162 bearerToken, // will look up the userId from this
163 branch_id: branchId,

Townieusage-dashboard.ts3 matches

@valdottownUpdated 23 hours ago
76 SUM(num_images) as total_images
77 FROM ${USAGE_TABLE}
78 WHERE our_api_token = 1
79 GROUP BY user_id, username
80 ORDER BY total_price DESC
256 <th>Finish</th>
257 <th>Images</th>
258 <th>Our API</th>
259 </tr>
260 </thead>
276 <td>${row.finish_reason}</td>
277 <td>${formatNumber(row.num_images)}</td>
278 <td>${formatBoolean(row.our_api_token)}</td>
279 </tr>
280 `).join("")

Townieschema.tsx2 matches

@valdottownUpdated 23 hours ago
17 finish_reason: string;
18 num_images: number;
19 our_api_token: boolean;
20}
21
37 finish_reason TEXT,
38 num_images INTEGER,
39 our_api_token INTEGER NOT NULL
40 )
41 `);

Towniequeries.tsx5 matches

@valdottownUpdated 23 hours ago
24 user_id = ?
25 AND timestamp > ?
26 AND our_api_token = 1
27 `,
28 [userId, new Date().getTime() - 24 * 60 * 60 * 1000],
55 finish_reason,
56 num_images,
57 our_api_token,
58}: {
59 bearerToken: string;
67 finish_reason: string;
68 num_images: number;
69 our_api_token: boolean;
70}) {
71 const price = calculateCost({
91 finish_reason,
92 num_images,
93 our_api_token
94 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
95 `,
108 finish_reason,
109 num_images,
110 our_api_token ? 1 : 0,
111 ],
112 );

telegramBotStarterwebhookInfo.tsx1 match

@asdfgUpdated 23 hours ago
6 const botToken = process.env.TELEGRAM_BOT_TOKEN;
7
8 const response = await fetch(`https://api.telegram.org/bot${botToken}/getWebhookInfo`);
9 const result = await response.json();
10 return result;

blob_adminmain.tsx6 matches

@fredmoonUpdated 1 day ago
14
15// Public route without authentication
16app.get("/api/public/:id", async (c) => {
17 const key = `__public/${c.req.param("id")}`;
18 const { blob } = await import("https://esm.town/v/std/blob");
132};
133
134app.get("/api/blobs", checkAuth, async (c) => {
135 const prefix = c.req.query("prefix") || "";
136 const limit = parseInt(c.req.query("limit") || "20", 10);
141});
142
143app.get("/api/blob", checkAuth, async (c) => {
144 const key = c.req.query("key");
145 if (!key) return c.text("Missing key parameter", 400);
149});
150
151app.put("/api/blob", checkAuth, async (c) => {
152 const key = c.req.query("key");
153 if (!key) return c.text("Missing key parameter", 400);
158});
159
160app.delete("/api/blob", checkAuth, async (c) => {
161 const key = c.req.query("key");
162 if (!key) return c.text("Missing key parameter", 400);
166});
167
168app.post("/api/blob", checkAuth, async (c) => {
169 const { file, key } = await c.req.parseBody();
170 if (!file || !key) return c.text("Missing file or key", 400);

blob_adminapp.tsx19 matches

@fredmoonUpdated 1 day ago
70 const menuRef = useRef(null);
71 const isPublic = blob.key.startsWith("__public/");
72 const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
73
74 useEffect(() => {
234 setLoading(true);
235 try {
236 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237 const data = await response.json();
238 setBlobs(data);
261 setBlobContentLoading(true);
262 try {
263 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264 const content = await response.text();
265 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
275 const handleSave = async () => {
276 try {
277 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278 method: "PUT",
279 body: editContent,
287 const handleDelete = async (key) => {
288 try {
289 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290 setBlobs(blobs.filter(b => b.key !== key));
291 if (selectedBlob && selectedBlob.key === key) {
304 const key = `${searchPrefix}${file.name}`;
305 formData.append("key", encodeKey(key));
306 await fetch("/api/blob", { method: "POST", body: formData });
307 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308 setBlobs([newBlob, ...blobs]);
326 try {
327 const fullKey = `${searchPrefix}${key}`;
328 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329 method: "PUT",
330 body: "",
341 const handleDownload = async (key) => {
342 try {
343 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344 const blob = await response.blob();
345 const url = window.URL.createObjectURL(blob);
360 if (newKey && newKey !== oldKey) {
361 try {
362 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363 const content = await response.blob();
364 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365 method: "PUT",
366 body: content,
367 });
368 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370 if (selectedBlob && selectedBlob.key === oldKey) {
380 const newKey = `__public/${key}`;
381 try {
382 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383 const content = await response.blob();
384 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385 method: "PUT",
386 body: content,
387 });
388 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390 if (selectedBlob && selectedBlob.key === key) {
399 const newKey = key.slice(9); // Remove "__public/" prefix
400 try {
401 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402 const content = await response.blob();
403 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404 method: "PUT",
405 body: content,
406 });
407 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409 if (selectedBlob && selectedBlob.key === key) {
554 onClick={() =>
555 copyToClipboard(
556 `${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
557 )}
558 className="text-blue-400 hover:text-blue-300 text-sm"
577 >
578 <img
579 src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
580 alt="Blob content"
581 className="max-w-full h-auto"

untitled-2604new-file-9513.tsx24 matches

@al0Updated 1 day ago
1// Creado por Alfonso Boldo
2// Sistema Completo de Prueba de APIs de LLMs para ValTown
3// Fecha: 05 de mayo de 2025
4
26 }
27
28 // Para solicitudes POST, procesar la llamada a la API
29 if (req.method === 'POST') {
30 try {
57
58 // Extraer parámetros
59 const { provider, apiKey, prompt, model, temperature, maxTokens } = body || {};
60
61 // Validar parámetros requeridos
62 if (!provider || !apiKey || !prompt) {
63 return new Response(
64 JSON.stringify({
65 error: 'Se requieren los parámetros: provider, apiKey y prompt'
66 }),
67 { status: 400, headers }
74 switch (provider.toLowerCase()) {
75 case 'openai':
76 result = await callOpenAI(apiKey, prompt, model || 'gpt-4o', temperature || 0.7, maxTokens || 1000);
77 break;
78 case 'anthropic':
79 result = await callClaude(apiKey, prompt, model || 'claude-3-5-sonnet-20240521', temperature || 0.7, maxTokens || 1000);
80 break;
81 default:
111}
112
113// Función para llamar a la API de OpenAI
114async function callOpenAI(apiKey, prompt, model, temperature, maxTokens) {
115 const url = 'https://api.openai.com/v1/chat/completions';
116
117 console.log(`Llamando a OpenAI con modelo: ${model}`);
122 headers: {
123 'Content-Type': 'application/json',
124 'Authorization': `Bearer ${apiKey}`
125 },
126 body: JSON.stringify({
170}
171
172// Función para llamar a la API de Claude (Anthropic)
173async function callClaude(apiKey, prompt, model, temperature, maxTokens) {
174 const url = 'https://api.anthropic.com/v1/messages';
175
176 console.log(`Llamando a Claude con modelo: ${model}`);
181 headers: {
182 'Content-Type': 'application/json',
183 'x-api-key': apiKey,
184 'anthropic-version': '2023-06-01'
185 },
244 <meta charset="UTF-8">
245 <meta name="viewport" content="width=device-width, initial-scale=1.0">
246 <title>Probador de APIs de LLMs</title>
247 <style>
248 body {
329 </head>
330 <body>
331 <h1>Probador de APIs de LLMs</h1>
332 <p>Esta herramienta te permite probar diferentes APIs de modelos de lenguaje como OpenAI (ChatGPT) y Claude (Anthropic).</p>
333
334 <div class="container">
342
343 <div class="form-group">
344 <label for="apiKey">API Key:</label>
345 <input type="password" id="apiKey" placeholder="Ingresa tu API key aquí">
346 </div>
347
465 submitBtn.addEventListener('click', async function() {
466 const provider = document.getElementById('provider').value;
467 const apiKey = document.getElementById('apiKey').value;
468 const model = document.getElementById('model').value;
469 const temperature = parseFloat(document.getElementById('temperature').value);
472
473 // Validar campos
474 if (!apiKey || !prompt) {
475 alert('Por favor completa todos los campos requeridos.');
476 return;
482 rawResult.textContent = 'Cargando...';
483
484 // Obtener la URL actual para la API
485 // Como ahora todo está en un solo endpoint, simplemente usamos la misma URL
486 const endpointUrl = window.location.href;
492 const requestBody = {
493 provider,
494 apiKey,
495 prompt,
496 model,

morningmailmain.tsx1 match

@flymasterUpdated 1 day ago
19async function wikitext(): string {
20 const randomArticle = await fetch(
21 "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro&explaintext&redirects=1&generator=random&formatversion=2&grnnamespace=0&grnlimit=3",
22 );
23 const articleJson = await randomArticle.json();

gptApiTemplate2 file matches

@charmaineUpdated 1 day ago

mod-interview-api1 file match

@twschillerUpdated 1 day ago
apiv1
socialdata
Affordable & reliable alternative to Twitter API: ➡️ Access user profiles, tweets, followers & timeline data in real-time ➡️ Monitor profiles with nearly instant alerts for new tweets, follows & profile updates ➡️ Simple integration