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/$%7Burl%7D?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 11489 results for "api"(942ms)

untitled-2604new-file-9513.tsx24 matches

@al0β€’Updated 36 mins ago
1// Creado por Alfonso Boldo
2// Sistema de Prueba de APIs de LLMs para ValTown
3// Fecha: 05 de mayo de 2025
4
5// Este sistema permite probar distintas APIs de LLMs como ChatGPT (OpenAI) y Claude (Anthropic)
6// Puede implementarse en ValTown como un endpoint HTTP
7
26
27 // Extraer parΓ‘metros
28 const { provider, apiKey, prompt, model, temperature, maxTokens } = body;
29
30 // Validar parΓ‘metros requeridos
31 if (!provider || !apiKey || !prompt) {
32 return new Response(
33 JSON.stringify({
34 error: 'Se requieren los parΓ‘metros: provider, apiKey y prompt'
35 }),
36 { status: 400, headers }
43 switch (provider.toLowerCase()) {
44 case 'openai':
45 result = await callOpenAI(apiKey, prompt, model || 'gpt-4o', temperature || 0.7, maxTokens || 1000);
46 break;
47 case 'anthropic':
48 result = await callClaude(apiKey, prompt, model || 'claude-3-5-sonnet-20240521', temperature || 0.7, maxTokens || 1000);
49 break;
50 default:
73}
74
75// FunciΓ³n para llamar a la API de OpenAI
76async function callOpenAI(apiKey, prompt, model, temperature, maxTokens) {
77 const url = 'https://api.openai.com/v1/chat/completions';
78
79 const response = await fetch(url, {
81 headers: {
82 'Content-Type': 'application/json',
83 'Authorization': `Bearer ${apiKey}`
84 },
85 body: JSON.stringify({
108}
109
110// FunciΓ³n para llamar a la API de Claude (Anthropic)
111async function callClaude(apiKey, prompt, model, temperature, maxTokens) {
112 const url = 'https://api.anthropic.com/v1/messages';
113
114 const response = await fetch(url, {
116 headers: {
117 'Content-Type': 'application/json',
118 'x-api-key': apiKey,
119 'anthropic-version': '2023-06-01'
120 },
153 <meta charset="UTF-8">
154 <meta name="viewport" content="width=device-width, initial-scale=1.0">
155 <title>Probador de APIs de LLMs</title>
156 <style>
157 body {
232 </head>
233 <body>
234 <h1>Probador de APIs de LLMs</h1>
235 <p>Esta herramienta te permite probar diferentes APIs de modelos de lenguaje como OpenAI (ChatGPT) y Claude (Anthropic).</p>
236
237 <div class="container">
245
246 <div class="form-group">
247 <label for="apiKey">API Key:</label>
248 <input type="password" id="apiKey" placeholder="Ingresa tu API key aquΓ­">
249 </div>
250
353 submitBtn.addEventListener('click', async () => {
354 const provider = document.getElementById('provider').value;
355 const apiKey = document.getElementById('apiKey').value;
356 const model = document.getElementById('model').value;
357 const temperature = parseFloat(document.getElementById('temperature').value);
360
361 // Validar campos
362 if (!apiKey || !prompt) {
363 alert('Por favor completa todos los campos requeridos.');
364 return;
371
372 // URL del endpoint (reemplaza con la URL real de tu Val en ValTown)
373 const endpointUrl = 'https://api.val.town/v1/run/tu-usuario/llm-api-tester';
374
375 // Enviar solicitud
381 body: JSON.stringify({
382 provider,
383 apiKey,
384 prompt,
385 model,

morningmailmain.tsx1 match

@flymasterβ€’Updated 36 mins ago
11async function wikitext(): string {
12 const randomArticle = await fetch(
13 "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",
14 );
15 const articleJson = await randomArticle.json();

LEDStrain-Discussion-To-PlainTextapp.tsx2 matches

@tyler71β€’Updated 1 hour ago
81async function getDiscussionPosts(discussionId: string): Promise<PostT[]> {
82 // Used to get the list of post id's for the discussion.
83 const discussionRes = await fetch(`${server}/api/discussions/${discussionId}`);
84 const discussionResJson = await discussionRes.json();
85
93
94 await Promise.all(chunks.map(async (c: string[]) => {
95 const postRes = await fetch(`${server}/api/posts?filter[id]=${c.join(",")}`);
96 const postJson = await postRes.json();
97

slack-prgithub-pr-inherit-labels.ts9 matches

@charmaineβ€’Updated 1 hour ago
198 }
199
200 const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
201 console.log("πŸ” Fetching issue from:", url);
202
209 });
210
211 console.log("πŸ” GitHub API response status:", response.status);
212
213 if (!response.ok) {
215 try {
216 const error = await response.json();
217 console.error("❌ GitHub API error:", JSON.stringify(error));
218 errorMessage = error.message || errorMessage;
219 } catch (e) {
220 const errorText = await response.text();
221 console.error("❌ GitHub API error text:", errorText);
222 }
223 throw new Error(`Failed to fetch issue: ${errorMessage}`);
237
238 try {
239 const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/labels`;
240 console.log("πŸ” Sending labels update request to:", url);
241
253 });
254
255 console.log("πŸ” GitHub API response status:", response.status);
256
257 if (response.ok) {
264 try {
265 const error = await response.json();
266 console.error("❌ GitHub API error:", JSON.stringify(error));
267 errorMessage = error.message || errorMessage;
268 } catch (e) {
269 const errorText = await response.text();
270 console.error("❌ GitHub API error text:", errorText);
271 }
272 return { success: false, message: errorMessage };
273 }
274 } catch (error) {
275 console.error("❌ Exception during API call:", error);
276 return { success: false, message: error.message };
277 }

slack-prREADME.md3 matches

@charmaineβ€’Updated 1 hour ago
38
391. **Create a Slack App**:
40 - Go to [Slack API Apps](https://api.slack.com/apps) β†’ Create New App β†’ From scratch
41 - Name your app and select your workspace
42 - Click "Create App"
774. If the merge button is clicked, the Val:
78 - Receives the interaction from Slack
79 - Uses the GitHub API to merge the PR
80 - Sends a confirmation message back to Slack
81
122- **Webhook not triggering**: Check the webhook delivery logs in GitHub repository settings
123- **Labels not copying**: Ensure the issue numbers are properly referenced in the PR description
124- **403 errors with GitHub API**: Your token doesn't have sufficient permissions. For most operations, you need:
125 - Classic tokens: "repo" scope
126 - Fine-grained tokens: "Read and Write" access to relevant resources (PRs, Issues, etc.)

slack-prgithub-pr-auto-assign.ts5 matches

@charmaineβ€’Updated 1 hour ago
155
156 try {
157 const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/assignees`;
158 console.log("πŸ” Sending assignee request to:", url);
159
171 });
172
173 console.log("πŸ” GitHub API response status:", response.status);
174
175 if (response.ok) {
181 try {
182 const error = await response.json();
183 console.error("❌ GitHub API error:", JSON.stringify(error));
184 errorMessage = error.message || errorMessage;
185
194 } catch (e) {
195 const errorText = await response.text();
196 console.error("❌ GitHub API error text:", errorText);
197 }
198 return { success: false, message: errorMessage };
199 }
200 } catch (error) {
201 console.error("❌ Exception during API call:", error);
202 return { success: false, message: error.message };
203 }

slack-prgithub-pr-title-prefix.ts5 matches

@charmaineβ€’Updated 2 hours ago
162
163 try {
164 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
165 console.log("πŸ” Sending title update request to:", url);
166
178 });
179
180 console.log("πŸ” GitHub API response status:", response.status);
181
182 if (response.ok) {
188 try {
189 const error = await response.json();
190 console.error("❌ GitHub API error:", JSON.stringify(error));
191 errorMessage = error.message || errorMessage;
192 } catch (e) {
193 const errorText = await response.text();
194 console.error("❌ GitHub API error text:", errorText);
195 }
196 return { success: false, message: errorMessage };
197 }
198 } catch (error) {
199 console.error("❌ Exception during API call:", error);
200 return { success: false, message: error.message };
201 }

slack-prgithub-slack-pr-approvals.ts16 matches

@charmaineβ€’Updated 2 hours ago
34};
35
36// Types for Slack API
37type SlackMessage = {
38 blocks: any[];
372
373 // Get PR details
374 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
375 console.log("πŸ” Fetching from GitHub API URL:", url);
376
377 let response;
384 }
385 });
386 console.log("πŸ” GitHub API response received");
387 console.log("πŸ” Response status:", response.status);
388 console.log("πŸ” Response status text:", response.statusText);
395
396 if (!response.ok) {
397 console.error(`❌ GitHub API error: ${response.status} ${response.statusText}`);
398
399 let errorText;
400 try {
401 errorText = await response.text();
402 console.error("❌ GitHub API error response:", errorText);
403
404 try {
405 // Try to parse as JSON for more details
406 const errorJson = JSON.parse(errorText);
407 console.error("❌ GitHub API error details:", JSON.stringify(errorJson));
408 } catch (e) {
409 // Not JSON, that's fine
419 try {
420 data = await response.json();
421 console.log("πŸ” Successfully parsed GitHub API response");
422 } catch (jsonError) {
423 console.error("❌ Failed to parse GitHub API response:", jsonError);
424
425 try {
430 }
431
432 throw new Error(`Failed to parse GitHub API response: ${jsonError.message}`);
433 }
434
446}
447
448// Merge a PR via GitHub API
449async function mergePR(repo: string, prNumber: number) {
450 console.log(`πŸ” Starting mergePR for PR #${prNumber} in ${repo}`);
494
495 // Proceed with merge
496 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/merge`;
497 console.log("πŸ” Sending merge request to:", url);
498
514 body: mergeBody
515 });
516 console.log("πŸ” Merge API response received");
517 console.log("πŸ” Response status:", response.status);
518 console.log("πŸ” Response status text:", response.statusText);
683 body: JSON.stringify(message)
684 });
685 console.log("πŸ” Slack API response received");
686 console.log("πŸ” Response status:", response.status);
687 console.log("πŸ” Response status text:", response.statusText);
694
695 if (!response.ok) {
696 console.error(`❌ Slack API error: ${response.status} ${response.statusText}`);
697
698 let errorText;
699 try {
700 errorText = await response.text();
701 console.error("❌ Slack API error response:", errorText);
702 } catch (e) {
703 console.error("❌ Could not read error response:", e);

Towniesend-message.ts3 matches

@valdottownβ€’Updated 2 hours ago
19 }
20
21 const { messages, project, branchId, anthropicApiKey, selectedFiles, images } = await c.req.json();
22 console.log("Original messages:", JSON.stringify(messages, null, 2));
23 console.log("Images received:", JSON.stringify(images, null, 2));
24
25 // Still allow users to pass their own key, or use ours
26 const apiKey = anthropicApiKey || Deno.env.get("ANTHROPIC_API_KEY");
27 const anthropic = createAnthropic({
28 apiKey,
29 });
30

TownieuseAuth.tsx11 matches

@valdottownβ€’Updated 2 hours ago
3
4const TOKEN_KEY = "bearer";
5const ANTHROPIC_KEY = "anthropic_api_key";
6
7export function useAuth() {
8 const [token, setToken, removeToken] = useLocalStorage(TOKEN_KEY, "");
9 const [anthropicApiKey, setAnthropicApiKey, removeAnthropicApiKey] = useLocalStorage(ANTHROPIC_KEY, "");
10 const [error, setError] = useState(null);
11
12 const isAuthenticated = !!token;
13
14 const authenticate = async (valTownAPIKey: string, anthropicKey: string) => {
15 // replace all this with oauth when it's ready
16 try {
17 const res = await fetch("/api/user", {
18 headers: {
19 "Authorization": "Bearer " + valTownAPIKey,
20 },
21 });
25 setError(data.error);
26 removeToken();
27 removeAnthropicApiKey();
28 return;
29 }
30 setError(null);
31 setToken(valTownAPIKey);
32 setAnthropicApiKey(anthropicKey);
33 } catch (e) {
34 console.error(e);
35 setError(e.error);
36 removeToken();
37 removeAnthropicApiKey();
38 }
39 };
41 const logOut = () => {
42 removeToken();
43 removeAnthropicApiKey();
44 };
45
50 logOut,
51 token,
52 anthropicApiKey,
53 };
54}

gptApiTemplate2 file matches

@charmaineβ€’Updated 5 hours ago

mod-interview-api1 file match

@twschillerβ€’Updated 21 hours ago
apiv1
papimark21