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/%7Bresult.originalUrl%7D?q=api&page=5&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 25402 results for "api"(1943ms)

NowPlayingGrabbermain.tsx2 matches

@yaoge•Updated 23 hours ago
2import querystring from "npm:querystring";
3
4const NOW_PLAYING_ENDPOINT = "https://api.spotify.com/v1/me/player/currently-playing";
5const TOKEN_ENDPOINT = "https://accounts.spotify.com/api/token";
6
7const client_id = Deno.env.get("spotify_client_id");

cronemain.ts1 match

@jrmann100•Updated 1 day ago
29 c.redirect(`https://discord.com/oauth2/authorize?client_id=${CLIENT_ID}`)
30);
31app.post("/api/interactions", verify, handleInteraction);
32
33export default app.fetch;

GLM-4-5-Omnimain.tsx12 matches

@aibotcommander•Updated 1 day ago
24 provider: "groq",
25 model: "meta-llama/llama-4-maverick-17b-128e-instruct",
26 endpoint: "https://api.groq.com/openai/v1/chat/completions",
27 headers: {
28 "Authorization": `Bearer ${process.env.GROQ_API_KEY}`,
29 "Content-Type": "application/json",
30 },
35 provider: "groq",
36 model: "meta-llama/llama-4-scout-17b-16e-instruct",
37 endpoint: "https://api.groq.com/openai/v1/chat/completions",
38 headers: {
39 "Authorization": `Bearer ${process.env.GROQ_API_KEY}`,
40 "Content-Type": "application/json",
41 },
46 provider: "openrouter",
47 model: "deepseek/deepseek-r1-distill-llama-70b",
48 endpoint: "https://openrouter.ai/api/v1/chat/completions",
49 headers: {
50 "Authorization": `Bearer ${process.env.OPEN_ROUTER_API_KEY}`,
51 "Content-Type": "application/json",
52 "HTTP-Referer": process.env.HTTP_REFERER || "https://localhost:3000",
58 provider: "deepseek",
59 model: "deepseek-chat",
60 endpoint: "https://api.deepseek.com/v1/chat/completions",
61 headers: {
62 "Authorization": `Bearer ${process.env.DEEPSEEK_API_KEY}`,
63 "Content-Type": "application/json",
64 },
602
603 for (const config of modelsToTry) {
604 const apiKey = process.env[`${config.provider.toUpperCase()}_API_KEY`] ||
605 process
606 .env[
607 `${
608 config.provider.replace("openrouter", "OPEN_ROUTER").toUpperCase()
609 }_API_KEY`
610 ];
611 if (!apiKey) continue;
612
613 try {
634 send("error", {
635 text:
636 "All configured models failed. Please check your API keys and try again.",
637 allow_retry: true,
638 });

untitled-7197main.ts15 matches

@sammy•Updated 1 day ago
8
9 try {
10 // 1. Get the Vapi request body
11 const body = await req.json();
12
15 if (!toolCall) {
16 return new Response(
17 JSON.stringify({ error: "Invalid Vapi tool call format" }),
18 { status: 400 },
19 );
31 }
32
33 // 3. Get the Bing API Key from environment secrets
34 const BING_API_KEY = Deno.env.get("BING_API_KEY");
35 if (!BING_API_KEY) {
36 console.error("BING_API_KEY secret is not set.");
37 return new Response(
38 JSON.stringify({
39 error: "Server configuration error: Missing API key.",
40 }),
41 { status: 500 },
43 }
44
45 // 4. Construct the search query and call the Bing API
46 const searchQuery = `${businessName} ${location}`;
47 const bingUrl = `https://api.bing.microsoft.com/v7.0/search?q=${
48 encodeURIComponent(searchQuery)
49 }&count=3`;
50
51 const bingResponse = await fetch(bingUrl, {
52 headers: { "Ocp-Apim-Subscription-Key": BING_API_KEY },
53 });
54
55 if (!bingResponse.ok) {
56 throw new Error(
57 `Bing API request failed with status: ${bingResponse.status}`,
58 );
59 }
69 }
70
71 // 6. Send the formatted result back to Vapi
72 const vapiResponse = {
73 results: [{
74 toolCallId: toolCallId,
77 };
78
79 return new Response(JSON.stringify(vapiResponse), {
80 headers: { "Content-Type": "application/json" },
81 status: 200,
82 });
83 } catch (error) {
84 console.error("Error in Vapi tool handler:", error);
85 return new Response(
86 JSON.stringify({ error: "An internal server error occurred." }),

openai-usagemain.ts2 matches

@nbbaier•Updated 1 day ago
37 do {
38 const url: string = page
39 ? `https://api.openai.com/v1/organization/costs?start_time=${startTime}&limit=${days}&page=${page}`
40 : `https://api.openai.com/v1/organization/costs?start_time=${startTime}&limit=${days}`;
41
42 const { data, error } = await betterFetch<Page<CostsObject>>(url, {

inlinemain.ts7 matches

@realtime•Updated 1 day ago
122 };
123 console.log(
124 "--- OpenAI API Request [1/2] ---",
125 JSON.stringify(requestPayload, null, 2),
126 );
130 // --- AUDIT LOG: Initial Response ---
131 console.log(
132 "--- OpenAI API Response [1/2] ---",
133 JSON.stringify(response, null, 2),
134 );
168 };
169 console.log(
170 "--- OpenAI API Request [2/2] ---",
171 JSON.stringify(finalRequestPayload, null, 2),
172 );
178 // --- AUDIT LOG: Final Response ---
179 console.log(
180 "--- OpenAI API Response [2/2] ---",
181 JSON.stringify(finalResponse, null, 2),
182 );
198// --- REFACTORED: HTML & MODERN UI ---
199function generateHtml(sourceUrl: string) {
200 return `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Dynamic Multi-Agent Analysis</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Code+Pro:wght@400;600&display=swap" rel="stylesheet"><style>:root{--bg-dark:#0a0a0f;--bg-med:#101018;--bg-light:#1a1a23;--border-color:rgba(255,255,255,0.1);--text-light:#f0f0f5;--text-med:#a0a0b0;--text-dark:#6c6c7a;--accent-primary:#007bff;--accent-secondary:#8a2be2;--status-green:#00c853;--status-red:#ff3d00;--status-orange:#ffab00;--font-sans:'Inter',sans-serif;--font-mono:'Source Code Pro',monospace;--shadow-sm:0 4px 6px rgba(0,0,0,0.1);--shadow-md:0 10px 15px rgba(0,0,0,0.1)}*,*::before,*::after{box-sizing:border-box}body{font-family:var(--font-sans);background-color:var(--bg-dark);color:var(--text-light);margin:0;padding:2rem;display:grid;place-items:center;min-height:100vh;background-image:radial-gradient(circle at 10% 10%,rgba(0,123,255,0.1),transparent 30%),radial-gradient(circle at 90% 80%,rgba(138,43,226,0.1),transparent 30%)}main{width:100%;max-width:900px;display:flex;flex-direction:column;gap:2rem}header{text-align:center}h1{font-size:2.25rem;font-weight:700;margin:0;color:var(--text-light)}h1 span{font-family:var(--font-mono);font-size:1rem;color:var(--text-med);margin-left:0.5rem;font-weight:400}.card{border:1px solid var(--border-color);border-radius:12px;padding:1.5rem 2rem;background:rgba(16,16,24,0.6);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);box-shadow:var(--shadow-sm)}.form-group{display:flex;flex-direction:column;gap:.5rem;margin-bottom:1rem}label{font-weight:600;font-size:.9rem;color:var(--text-med)}textarea,input{background-color:var(--bg-med);border:1px solid var(--border-color);border-radius:8px;padding:.75rem;color:var(--text-light);font-family:var(--font-sans);font-size:1rem;transition:border-color .2s,box-shadow .2s}textarea:focus,input:focus{outline:none;border-color:var(--accent-primary);box-shadow:0 0 0 3px rgba(0,123,255,0.2)}textarea{min-height:100px;font-family:var(--font-mono);resize:vertical}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.full-width{grid-column:1/-1}button{grid-column:1/-1;background-image:linear-gradient(90deg,var(--accent-primary),var(--accent-secondary));color:white;border:none;padding:1rem;font-size:1.1rem;font-weight:600;border-radius:8px;cursor:pointer;transition:transform .2s,opacity .2s,box-shadow .2s;box-shadow:var(--shadow-sm)}button:hover{transform:translateY(-2px);box-shadow:var(--shadow-md)}button:disabled{opacity:.5;cursor:not-allowed;transform:none;box-shadow:none}#results{display:none}#round-status{text-align:center;color:var(--text-med);margin:0 0 1.5rem;font-weight:500;font-size:1.1rem}#workflow-container{display:flex;flex-direction:column;gap:1.5rem}.report-card{opacity:0;transform:translateY(20px);transition:opacity 0.5s ease,transform 0.5s ease;position:relative;padding-left:2.5rem}.report-card.visible{opacity:1;transform:translateY(0)}.report-card::before{content:'';position:absolute;left:1rem;top:1rem;width:2px;background:var(--border-color);height:calc(100% - 1rem)}.report-card:last-child::before{display:none}.report-card::after{content:'';position:absolute;left:calc(1rem - 9px);top:0.75rem;width:20px;height:20px;border-radius:50%;background-color:var(--bg-med);border:2px solid var(--border-color);z-index:1}.report-card-header{display:flex;align-items:center;gap:0.75rem;margin-bottom:0.75rem}.report-card-header h3{margin:0;font-size:1.2rem;color:var(--text-light)}.report-card-body p{margin:0;color:var(--text-med);line-height:1.6}.report-card-body strong{color:var(--text-light);font-weight:600}.report-card[data-status="pending"]::after{background-color:var(--bg-dark);border-color:var(--accent-primary)}.report-card[data-status="success"]::after{background-color:var(--status-green);border-color:var(--status-green)}.report-card[data-status="failure"]::after{background-color:var(--status-red);border-color:var(--status-red)}.report-card[data-agent-type="summary"]::after{border-color:var(--accent-secondary)}.report-card[data-agent-type="audit"]::after{border-color:var(--status-orange)}.status-icon{font-size:1.1rem}.boolean-true{color:var(--status-green)}.boolean-false{color:var(--status-red)}.spinner{width:16px;height:16px;border:2px solid var(--text-dark);border-top-color:var(--accent-primary);border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}</style></head><body><main><header><h1>Dynamic Agent Workflow <span>v5.0</span></h1></header><section class="card"><form id="analysis-form"><div class="form-grid"><div class="form-group full-width"><label for="prompt">Original Prompt</label><textarea id="prompt" name="prompt" required>Calculate the total distance a car travels if it moves at 60 mph for 2 hours and then 70 mph for 1 hour.</textarea></div><div class="form-group"><label for="supposed_correct_response">Supposed Correct Response</label><input id="supposed_correct_response" name="supposed_correct_response" value="190 miles" required></div><div class="form-group"><label for="final_answer">Final Answer to Check</label><input id="final_answer" name="final_answer" value="190 miles" required></div><div class="form-group full-width"><label for="reasoning_steps">Reasoning Steps</label><textarea id="reasoning_steps" name="reasoning_steps" required>1. First part of the trip: distance = speed × time = 60 mph × 2 hours = 120 miles.
2012. Second part of the trip: distance = speed × time = 70 mph × 1 hour = 70 miles.
2023. Total distance = 120 miles + 70 miles = 190 miles.</textarea></div><button type="submit" id="submit-btn">Analyze Response</button></div></form></section><section id="results" class="card"><h2 id="round-status"></h2><div id="workflow-container"></div></section></main><script>
232 async function runAgent(agentName, state, agentType) {
233 const card = createAgentCard(agentName, agentType);
234 const response = await fetch(\`/api/run-agent/\${agentName}\`, {
235 method: 'POST',
236 headers: { 'Content-Type': 'application/json' },
330const app = new Hono();
331
332app.post("/api/run-agent/:agent", async (c) => {
333 const agentName = c.req.param("agent");
334 const agentConfig = AGENT_CONFIG[agentName];

consistmain.ts3 matches

@know•Updated 1 day ago
212// The client-side script is now the orchestrator.
213function generateHtml(sourceUrl: string) {
214 return `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Client-Side Multi-Agent Analysis</title><link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Source+Code+Pro:wght@400;600&display=swap" rel="stylesheet"><style>:root{--bg:#0d1117;--card-bg:#161b22;--border:#30363d;--text:#c9d1d9;--text-muted:#8b949e;--accent:#58a6ff;--green:#3fb950;--red:#f85149;--orange:#f5a623}*,*::before,*::after{box-sizing:border-box}body{font-family:'Inter',sans-serif;background-color:var(--bg);color:var(--text);margin:0;padding:2rem;display:grid;place-items:center;min-height:100vh}main{width:100%;max-width:900px;display:flex;flex-direction:column;gap:2rem}h1{font-size:2rem;text-align:center;margin-bottom:.5rem}h1 span{font-family:'Source Code Pro',monospace;font-size:1rem;color:var(--text-muted)}.card{background-color:var(--card-bg);border:1px solid var(--border);border-radius:8px;padding:1.5rem}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:1rem}.form-group{display:flex;flex-direction:column;gap:.5rem}.full-width{grid-column:1/-1}label{font-weight:600;font-size:.9rem}textarea,input{background-color:var(--bg);border:1px solid var(--border);border-radius:6px;padding:.75rem;color:var(--text);font-family:'Inter',sans-serif;font-size:1rem;resize:vertical}textarea{min-height:120px;font-family:'Source Code Pro',monospace}button{grid-column:1/-1;background-color:var(--accent);color:var(--bg);border:none;padding:.75rem 1rem;font-size:1.1rem;font-weight:600;border-radius:6px;cursor:pointer;transition:opacity .2s}button:disabled{opacity:.5;cursor:not-allowed}#results{display:none}#round-status{text-align:center;color:var(--text-muted);margin-top:0;font-weight:500}#results-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:1.5rem;margin-top:1.5rem}.report-card{background-color:var(--bg);padding:1rem;border-radius:6px;border-left:4px solid var(--border);transition:all .3s ease-in-out;transform:translateY(10px);opacity:0}.report-card.visible{transform:translateY(0);opacity:1}.report-card h3{margin:0 0 .5rem;font-size:1.1rem;display:flex;align-items:center;gap:.5rem}.report-card p{margin:0;color:var(--text-muted);line-height:1.6}.verdict{border-left-color:var(--accent)}.verification{border-left-color:var(--orange)}.boolean-true{color:var(--green)}.boolean-false{color:var(--red)}.placeholder{display:flex;align-items:center;justify-content:center;min-height:80px;color:var(--text-muted);font-style:italic}.spinner{border:2px solid var(--border);border-top-color:var(--accent);border-radius:50%;width:16px;height:16px;animation:spin 1s linear infinite;margin-right:8px}@keyframes spin{to{transform:rotate(360deg)}}</style></head><body><main><header><h1>Client-Side Multi-Agent Analysis <span>v4.0</span></h1></header><section class="card"><form id="analysis-form"><div class="form-grid"><div class="form-group full-width"><label for="prompt">Original Prompt</label><textarea id="prompt" name="prompt" required>Calculate the total distance a car travels if it moves at 60 mph for 2 hours and then 70 mph for 1 hour.</textarea></div><div class="form-group"><label for="supposed_correct_response">Supposed Correct Response</label><input id="supposed_correct_response" name="supposed_correct_response" value="190 miles" required></div><div class="form-group"><label for="final_answer">Final Answer to Check</label><input id="final_answer" name="final_answer" value="190 miles" required></div><div class="form-group full-width"><label for="reasoning_steps">Reasoning Steps</label><textarea id="reasoning_steps" name="reasoning_steps" required>1. First part of the trip: distance = speed × time = 60 mph × 2 hours = 120 miles.
2152. Second part of the trip: distance = speed × time = 70 mph × 1 hour = 70 miles.
2163. Total distance = 120 miles + 70 miles = 190 miles.</textarea></div><button type="submit" id="submit-btn">Analyze Response</button></div></form></section><section id="results" class="card"><h2 id="round-status"></h2><div id="final-report" class="report-card verdict"></div><div id="results-grid"></div><div id="verification-report" class="report-card verification"></div></section></main><script>
251 }
252
253 const response = await fetch(\`/api/run-agent/\${agentName}\`, {
254 method: 'POST',
255 headers: { 'Content-Type': 'application/json' },
350
351// A single, stateless endpoint to run any agent
352app.post("/api/run-agent/:agent", async (c) => {
353 const agentName = c.req.param("agent");
354 const agentConfig = AGENT_CONFIG[agentName];

tanstack-basicposts.ts2 matches

@nbbaier•Updated 1 day ago
10};
11
12const API_URL = "https://jsonplaceholder.typicode.com";
13
14export const usePosts = () => {
17 queryFn: () =>
18 axios
19 .get<PostType[]>(`${API_URL}/posts`)
20 .then((r) => r.data.slice(0, 10)),
21 });

untitled-5100main.ts9 matches

@chatgot•Updated 1 day ago
15
16 const baseUrl =
17 `https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/seasons/${year}/segments/0/leagues/${leagueId}`;
18
19 // Team name to ID mapping
108 : parseInt(weekParam);
109
110 // Enhanced API call to get roster data too
111 const apiUrl =
112 `${baseUrl}?view=mMatchup&view=mMatchupScore&view=mTeam&view=mSettings&view=mBoxscore&view=mScoreboard&view=mRoster&view=mLiveScoring&scoringPeriodId=${targetWeek}`;
113
114 const response = await fetch(apiUrl, {
115 method: "GET",
116 headers: {
285
286 if (mode === "standings") {
287 const apiUrl = `${baseUrl}?view=mTeam&view=mStandings&view=mSettings`;
288
289 const response = await fetch(apiUrl, {
290 method: "GET",
291 headers: {
350 );
351
352 const apiUrl =
353 `${baseUrl}?view=mRoster&view=mTeam&view=mLiveScoring&view=mMatchupScore&scoringPeriodId=${currentWeek}&teamId=${actualTeamId}`;
354
355 const response = await fetch(apiUrl, {
356 method: "GET",
357 headers: {
415 // Default response
416 return Response.json({
417 message: "ESPN Fantasy API Connected",
418 availableModes: ["standings", "scoreboard", "roster"],
419 usage:

betterstackmain.tsx3 matches

@vov•Updated 1 day ago
17
18 const jwtResponse = await fetch(
19 `https://huggingface.co/api/spaces/altox/asd/jwt?expiration=${expirationDate}&include_pro_status=true`,
20 {
21 method: "GET",
31
32 // await fetch(
33 // "https://uptime.betterstack.com/api/v2/monitors/3276488",
34 // {
35 // method: "PATCH",
47
48 const response = await fetch(
49 "https://uptime.betterstack.com/api/v2/monitors/3276488",
50 {
51 method: "PATCH",

PixelPixelApiMonitor1 file match

@selfire1•Updated 9 hours ago
Regularly polls the API and messages on an error.

weatherApp1 file match

@dcm31•Updated 15 hours ago
A simple weather app with dropdown cities using Open-Meteo API
fapian
<("<) <(")> (>")>
Kapil01