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//%22https:/www.cesd73.ca/uploads/kurtretirementweb/1748903866-280w_kurtretirementweb.jpg/%22?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 25400 results for "api"(3048ms)

spotymain.ts2 matches

@skirtownerโ€ขUpdated 23 mins ago
19 const now = Date.now();
20 if (!cached.accessToken || now >= cached.expiresAt) {
21 const tokenResp = await fetch("https://accounts.spotify.com/api/token", {
22 method: "POST",
23 headers: {
45 let playlists: any[] = [];
46 let nextUrl: string | null =
47 "https://api.spotify.com/v1/me/playlists?limit=50";
48
49 while (nextUrl) {

eventsCalendarserver.ts6 matches

@roopโ€ขUpdated 1 hour ago
13
14import { Hono } from "npm:hono@4";
15import { SSEStreamingApi, stream, streamSSE } from "npm:hono@4/streaming";
16import { html, raw } from "npm:hono@4/html";
17import process from "node:process";
27 return streamSSE(c, async (stream) => {
28 // validate token
29 const apiToken = c.req.query("token");
30 if (apiToken !== process.env.API_TOKEN) {
31 await fail(stream, "Unauthorized");
32 return stream.close();
209});
210
211function update(stream: SSEStreamingApi, payload: any) {
212 return stream.writeSSE({
213 event: "update",
220
221function complete(
222 stream: SSEStreamingApi,
223 state: "success" | "error",
224) {
233
234function fail(
235 stream: SSEStreamingApi,
236 message?: string,
237) {

eventsCalendarlogs.tsx1 match

@roopโ€ขUpdated 1 hour ago
20export const dashboard = async (req) => {
21 const token = new URL(req.url).searchParams.get("token");
22 if (token !== process.env.API_TOKEN) {
23 return new Response("Token required to view logs", { status: 403 });
24 }

TopTenVideosREADME.md2 matches

@pmapowerโ€ขUpdated 2 hours ago
80```
81https://yoursite.com/custom-header.html
82https://api.yoursite.com/generate-header
83https://cdn.example.com/headers/analysis.html
84```
146- **Safe External Links**: `noopener noreferrer` attributes
147- **Input Validation**: URL validation for all inputs
148- **XSS Protection**: Proper HTML escaping
149- **Error Boundaries**: Graceful error handling
150

TopTenVideosindex.html2 matches

@pmapowerโ€ขUpdated 2 hours ago
674 });
675
676 // Here you could make an API call to your backend
677 console.log('Selected niche data:', {
678 niche,
767 `;
768
769 // Sample video data (you can replace this with real API data)
770 const sampleVideos = [
771 {

TopTenVideosindex.html30 matches

@pmapowerโ€ขUpdated 3 hours ago
90 <!-- Setup Instructions -->
91 <div id="setup-info" class="max-w-4xl mx-auto mt-12 bg-blue-50 border border-blue-200 rounded-lg p-6">
92 <h3 class="text-lg font-semibold text-blue-800 mb-3">๐Ÿ”ง YouTube API Setup Guide</h3>
93
94 <!-- API Key Tester -->
95 <div class="mb-6 bg-white p-4 rounded-lg border">
96 <h4 class="font-semibold text-gray-800 mb-3">๐Ÿงช Test Your API Key</h4>
97 <div class="flex gap-3">
98 <input
99 type="text"
100 id="test-api-key"
101 placeholder="Paste your YouTube API key here to test it..."
102 class="flex-1 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm font-mono"
103 >
113
114 <div class="mb-6">
115 <h4 class="font-semibold text-blue-800 mb-2">Step 1: Create API Key</h4>
116 <ol class="list-decimal list-inside text-blue-700 space-y-1 mb-4 ml-4">
117 <li>Go to <a href="https://console.developers.google.com/" target="_blank" class="underline font-medium">Google Cloud Console</a></li>
118 <li>Create a new project or select an existing one</li>
119 <li>Go to "APIs & Services" โ†’ "Library"</li>
120 <li>Search for and enable <strong>"YouTube Data API v3"</strong></li>
121 <li>Go to "APIs & Services" โ†’ "Credentials"</li>
122 <li>Click "Create Credentials" โ†’ "API Key"</li>
123 <li>Copy your API key</li>
124 </ol>
125 </div>
126
127 <div class="mb-6">
128 <h4 class="font-semibold text-blue-800 mb-2">Step 2: Configure API Key</h4>
129 <ol class="list-decimal list-inside text-blue-700 space-y-1 mb-4 ml-4">
130 <li>In Val Town, go to your environment variables</li>
131 <li>Add a new variable named: <code class="bg-blue-100 px-2 py-1 rounded font-mono">YOUTUBE_API_KEY</code></li>
132 <li>Paste your API key as the value</li>
133 <li>Save the environment variable</li>
134 </ol>
139 <div class="space-y-3 text-sm">
140 <div class="bg-white p-3 rounded border-l-4 border-yellow-400">
141 <strong class="text-gray-800">API Key Invalid Error:</strong>
142 <ul class="mt-1 text-gray-700 list-disc list-inside ml-4">
143 <li>Double-check your API key is copied correctly (no extra spaces)</li>
144 <li>Ensure YouTube Data API v3 is enabled in Google Cloud Console</li>
145 <li>Wait a few minutes after creating the key for it to activate</li>
146 <li>Try removing all API restrictions temporarily</li>
147 </ul>
148 </div>
150 <strong class="text-gray-800">Quota Exceeded Error:</strong>
151 <ul class="mt-1 text-gray-700 list-disc list-inside ml-4">
152 <li>YouTube API has daily quotas (10,000 units/day for free tier)</li>
153 <li>Each search uses ~100 units, so you can do ~100 searches per day</li>
154 <li>Reset happens at midnight Pacific Time</li>
159
160 <p class="text-sm text-blue-600">
161 ๐Ÿ’ก <strong>Good news:</strong> The YouTube Data API is completely free for personal use with generous daily quotas!
162 </p>
163 </div>
185
186 async handleTestKey() {
187 const testKeyInput = document.getElementById('test-api-key');
188 const testKeyBtn = document.getElementById('test-key-btn');
189 const resultDiv = document.getElementById('key-test-result');
190 const apiKey = testKeyInput.value.trim();
191
192 if (!apiKey) {
193 this.showKeyTestResult('Please enter an API key to test', 'error');
194 return;
195 }
198 testKeyBtn.textContent = 'Testing...';
199 resultDiv.className = 'mt-3 p-3 bg-gray-100 rounded text-sm';
200 resultDiv.innerHTML = '๐Ÿ”„ Testing API key...';
201 resultDiv.classList.remove('hidden');
202
203 try {
204 const response = await fetch('/api/test-key', {
205 method: 'POST',
206 headers: { 'Content-Type': 'application/json' },
207 body: JSON.stringify({ apiKey })
208 });
209 const data = await response.json();
210
211 if (data.success) {
212 this.showKeyTestResult(`โœ… API key is valid! Found ${data.sampleData.videoCount} video(s).`, 'success');
213 } else {
214 this.showKeyTestResult(`โŒ API key failed: ${data.error}`, 'error');
215 }
216 } catch (error) {
250
251 try {
252 const response = await fetch(`/api/videos?niche=${encodeURIComponent(niche)}`);
253 const data = await response.json();
254

TopTenVideosapp.js10 matches

@pmapowerโ€ขUpdated 3 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

@pmapowerโ€ขUpdated 3 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

@chatgotโ€ขUpdated 3 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, {

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

@gmcabritaโ€ขUpdated 3 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%3Dandroid%26start%3D0%26store%3DEGS",
17 );
18 const json = await response.json();

PixelPixelApiMonitor1 file match

@selfire1โ€ขUpdated 4 hours ago
Regularly polls the API and messages on an error.

weatherApp1 file match

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