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=348&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 5369 results for "api"(574ms)

groqAudioChatchat.ts9 matches

@arfanUpdated 1 month ago
12 console.log(`🔵 Last user message: "${messages.find(m => m.role === 'user')?.content?.substring(0, 50)}..."`);
13
14 const GROQ_API_KEY = Deno.env.get("GROQ_API_KEY");
15 if (!GROQ_API_KEY) {
16 console.error("❌ Missing GROQ_API_KEY environment variable");
17 return c.json({ error: "GROQ_API_KEY environment variable is not set" }, 500);
18 }
19
20 console.log("🔵 Sending request to Groq API");
21 const start = Date.now();
22 const response = await fetch("https://api.groq.com/openai/v1/chat/completions", {
23 method: "POST",
24 headers: {
25 "Content-Type": "application/json",
26 "Authorization": `Bearer ${GROQ_API_KEY}`
27 },
28 body: JSON.stringify({
33 });
34 const elapsed = Date.now() - start;
35 console.log(`🔵 Groq API response received in ${elapsed}ms, status: ${response.status}`);
36
37 if (!response.ok) {
38 const errorData = await response.json();
39 console.error("❌ Chat API error:", errorData);
40 return c.json({ error: "Failed to get chat completion", details: errorData }, response.status);
41 }

groqAudioChataudio.ts16 matches

@arfanUpdated 1 month ago
1import { Context } from "https://deno.land/x/hono@v3.11.7/mod.ts";
2
3// Function to handle audio transcription using Groq's Whisper API
4export const audioTranscriptionHandler = async (c: Context) => {
5 console.log("🎤 Audio transcription request received");
15 }
16
17 // Get API key from environment variable
18 const apiKey = Deno.env.get("GROQ_API_KEY");
19 if (!apiKey) {
20 console.error("❌ Transcription error: Missing API key");
21 return c.json({ error: "API key not configured" }, 500);
22 }
23
33
34 // If the file doesn't have a proper name or type, add one
35 // This ensures the file has the right extension for the API
36 if (!audioFile.name || !audioFile.type.startsWith('audio/')) {
37 const newFile = new File(
45 }
46
47 // Prepare the form data for Groq API
48 const groqFormData = new FormData();
49
60 groqFormData.append("timestamp_granularities[]", "word");
61
62 // Call Groq API
63 console.log("🎤 Sending request to Groq Whisper API");
64 const start = Date.now();
65 const response = await fetch("https://api.groq.com/openai/v1/audio/transcriptions", {
66 method: "POST",
67 headers: {
68 "Authorization": `Bearer ${apiKey}`
69 },
70 body: groqFormData
71 });
72 const elapsed = Date.now() - start;
73 console.log(`🎤 Groq Whisper API response received in ${elapsed}ms, status: ${response.status}`);
74
75 // Get response content type
94 errorMessage = `Server error: ${response.status} ${response.statusText}`;
95 // Log the full response for debugging
96 console.error("❌ Transcription API error response:", {
97 status: response.status,
98 statusText: response.statusText,
103 }
104 } catch (parseError) {
105 console.error("❌ Error parsing Groq API response:", parseError);
106 errorMessage = "Failed to parse error response from server";
107 }
108
109 return c.json({
110 error: `Groq API error: ${errorMessage}`,
111 status: response.status
112 }, response.status);

groqAudioChatalpine.ts10 matches

@arfanUpdated 1 month ago
261 // Now immediately send this message to get AI response
262 try {
263 // Prepare messages for the API
264 const apiMessages = this.messages.map(({ role, content }) => ({ role, content }));
265
266 // Ensure first message is always the correct system message for current mode
267 if (apiMessages.length > 0 && apiMessages[0].role === 'system') {
268 const systemMessage = this.chatMode === 'concise'
269 ? 'You are a helpful assistant powered by the Llama-3.3-70b-versatile model. Keep your responses short, concise and conversational. Aim for 1-3 sentences when possible.'
270 : 'You are a helpful assistant powered by the Llama-3.3-70b-versatile model. Respond conversationally and accurately to the user.';
271
272 apiMessages[0].content = systemMessage;
273 }
274
276 method: 'POST',
277 headers: { 'Content-Type': 'application/json' },
278 body: JSON.stringify({ messages: apiMessages })
279 });
280
339 this.statusMessage = 'Thinking...';
340
341 // Prepare messages for the API (excluding UI-only properties)
342 const apiMessages = this.messages.map(({ role, content }) => ({ role, content }));
343
344 // Ensure first message is always the correct system message for current mode
345 if (apiMessages.length > 0 && apiMessages[0].role === 'system') {
346 const systemMessage = this.chatMode === 'concise'
347 ? 'You are a helpful assistant powered by the Llama-3.3-70b-versatile model. Keep your responses short, concise and conversational. Aim for 1-3 sentences when possible.'
348 : 'You are a helpful assistant powered by the Llama-3.3-70b-versatile model. Respond conversationally and accurately to the user.';
349
350 apiMessages[0].content = systemMessage;
351 }
352
355 method: 'POST',
356 headers: { 'Content-Type': 'application/json' },
357 body: JSON.stringify({ messages: apiMessages })
358 });
359

MailGoatREADME.md4 matches

@kamalnrfUpdated 1 month ago
2Greatest of all time for your email!
3
4### Google API Configuration
51. Create a new Google Cloud Project
62. Configure OAuth Conscent Screen
8#### Scopes Needed
9**Read Metadata**
10- https://www.googleapis.com/auth/gmail.metadata
11- This allows you to read email metadata (subjects, headers, labels) but not the email content itself
12- Perfect for creating an email management system without needing to access sensitive message content
13
14**Labels**
15- https://www.googleapis.com/auth/gmail.labels
16- This is the scope for seeing and editing email labels
17- Allows you to create, delete, and modify labels
19
20### Todo
21- [ ] Google API Configuration
22- [ ] OAuth Implementation with Basic UI to trigger OAuth
23- [ ] Fetch Emails
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error

timelineApp.tsx4 matches

@tmcwUpdated 1 month ago
111 }, [gameState?.currentPlayerIndex, gameState?.currentCard?.id]);
112
113 // Fetch players from the API
114 const fetchPlayers = async () => {
115 try {
116 setLoading(true);
117 const response = await fetch("/api/players");
118 if (!response.ok) {
119 throw new Error("Failed to fetch players");
138 const deletePlayer = async (id: string) => {
139 try {
140 const response = await fetch(`/api/players/${id}`, {
141 method: "DELETE",
142 });
183 try {
184 // Fetch a card from the selected card set
185 const response = await fetch(`/api/card-sets/${cardSet.id}/cards`);
186 if (!response.ok) {
187 throw new Error("Failed to fetch cards");

timelineApp.tsx4 matches

@shouserUpdated 1 month ago
111 }, [gameState?.currentPlayerIndex, gameState?.currentCard?.id]);
112
113 // Fetch players from the API
114 const fetchPlayers = async () => {
115 try {
116 setLoading(true);
117 const response = await fetch("/api/players");
118 if (!response.ok) {
119 throw new Error("Failed to fetch players");
138 const deletePlayer = async (id: string) => {
139 try {
140 const response = await fetch(`/api/players/${id}`, {
141 method: "DELETE",
142 });
183 try {
184 // Fetch a card from the selected card set
185 const response = await fetch(`/api/card-sets/${cardSet.id}/cards`);
186 if (!response.ok) {
187 throw new Error("Failed to fetch cards");

timelineindex.ts19 matches

@tmcwUpdated 1 month ago
241initDb();
242
243// API routes for games
244app.get("/api/games", async (c) => {
245 const result = await sqlite.execute(`SELECT data FROM ${GAMES_TABLE}`);
246 const games = result.rows.map(row => JSON.parse(row.data as string)) as Game[];
248});
249
250app.get("/api/games/:id", async (c) => {
251 const id = c.req.param("id");
252 const result = await sqlite.execute(
263});
264
265app.post("/api/games", async (c) => {
266 const formData = await c.req.json() as GameFormData;
267 const game = formDataToGame(formData);
275});
276
277app.delete("/api/games/:id", async (c) => {
278 const id = c.req.param("id");
279
293});
294
295// API routes for game players
296app.get("/api/games/:gameId/players", async (c) => {
297 const gameId = c.req.param("gameId");
298
320});
321
322app.post("/api/games/:gameId/players", async (c) => {
323 const gameId = c.req.param("gameId");
324 const formData = await c.req.json() as PlayerFormData;
341});
342
343app.delete("/api/games/:gameId/players/:playerId", async (c) => {
344 const gameId = c.req.param("gameId");
345 const playerId = c.req.param("playerId");
354});
355
356// API routes for all players (not game-specific)
357app.get("/api/players", async (c) => {
358 const result = await sqlite.execute(`SELECT data FROM ${PLAYERS_TABLE}`);
359 const players = result.rows.map(row => JSON.parse(row.data as string)) as Player[];
361});
362
363app.post("/api/players", async (c) => {
364 const formData = await c.req.json() as PlayerFormData;
365 const player = formDataToPlayer(formData);
373});
374
375app.delete("/api/players/:id", async (c) => {
376 const id = c.req.param("id");
377
391});
392
393// API routes for card sets
394app.get("/api/card-sets", (c) => {
395 return c.json(CARD_SETS);
396});
397
398// API route to get cards from a specific set
399app.get("/api/card-sets/:setId/cards", (c) => {
400 const setId = c.req.param("setId");
401 const cards = SAMPLE_CARDS[setId] || [];
407});
408
409// API route to get a specific card
410app.get("/api/cards/:id", (c) => {
411 const cardId = c.req.param("id");
412

timelinePlayerForm.tsx1 match

@shouserUpdated 1 month ago
37
38 try {
39 const response = await fetch("/api/players", {
40 method: "POST",
41 headers: {

timelineNewGameForm.tsx1 match

@shouserUpdated 1 month ago
29
30 try {
31 const response = await fetch("/api/games", {
32 method: "POST",
33 headers: {

runValAPIEx2 file matches

@charmaineUpdated 1 day ago

PassphraseAPI2 file matches

@wolfUpdated 3 days ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)