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/image-url.jpg%20%22Image%20title%22?q=api&page=3&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 11519 results for "api"(3492ms)

162 }
163
164 const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
165
166 const response = await fetch(url, {
195
196 try {
197 const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/labels`;
198
199 const response = await fetch(url, {
32};
33
34// Types for Slack API
35type SlackMessage = {
36 blocks: any[];
219
220 // Get PR details
221 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
222
223 let response;
241 return await response.json();
242 } catch (jsonError) {
243 throw new Error(`Failed to parse GitHub API response: ${jsonError.message}`);
244 }
245}
246
247// Merge a PR via GitHub API
248async function mergePR(repo: string, prNumber: number) {
249 const token = Deno.env.get("GITHUB_TOKEN");
282
283 // Proceed with merge
284 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/merge`;
285
286 const response = await fetch(url, {
GitHub-PR-Automation

GitHub-PR-Automationgithub-pr-auto-assign.ts2 matches

@charmaineโ€ขUpdated 13 hours ago
99
100 try {
101 const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/assignees`;
102
103 const response = await fetch(url, {
132 }
133 } catch (error) {
134 console.error("Exception during API call:", error);
135 return { success: false, message: error.message };
136 }
GitHub-PR-Automation

GitHub-PR-Automationgithub-pr-auto-assign.ts5 matches

@charmaineโ€ขUpdated 13 hours ago
129
130 try {
131 const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/assignees`;
132 console.log("๐Ÿ” Sending assignee request to:", url);
133
145 });
146
147 console.log("๐Ÿ” GitHub API response status:", response.status);
148
149 if (response.ok) {
155 try {
156 const error = await response.json();
157 console.error("โŒ GitHub API error:", JSON.stringify(error));
158 errorMessage = error.message || errorMessage;
159
168 } catch (e) {
169 const errorText = await response.text();
170 console.error("โŒ GitHub API error text:", errorText);
171 }
172 return { success: false, message: errorMessage };
173 }
174 } catch (error) {
175 console.error("โŒ Exception during API call:", error);
176 return { success: false, message: error.message };
177 }
34};
35
36// Types for Slack API
37type SlackMessage = {
38 blocks: any[];
323
324 // Get PR details
325 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
326 console.log("๐Ÿ” Fetching from GitHub API URL:", url);
327
328 let response;
335 },
336 });
337 console.log("๐Ÿ” GitHub API response received");
338 console.log("๐Ÿ” Response status:", response.status);
339 console.log("๐Ÿ” Response status text:", response.statusText);
346
347 if (!response.ok) {
348 console.error(`โŒ GitHub API error: ${response.status} ${response.statusText}`);
349
350 let errorText;
351 try {
352 errorText = await response.text();
353 console.error("โŒ GitHub API error response:", errorText);
354
355 try {
356 // Try to parse as JSON for more details
357 const errorJson = JSON.parse(errorText);
358 console.error("โŒ GitHub API error details:", JSON.stringify(errorJson));
359 } catch (e) {
360 // Not JSON, that's fine
370 try {
371 data = await response.json();
372 console.log("๐Ÿ” Successfully parsed GitHub API response");
373 } catch (jsonError) {
374 console.error("โŒ Failed to parse GitHub API response:", jsonError);
375
376 try {
384 }
385
386 throw new Error(`Failed to parse GitHub API response: ${jsonError.message}`);
387 }
388
400}
401
402// Merge a PR via GitHub API
403async function mergePR(repo: string, prNumber: number) {
404 console.log(`๐Ÿ” Starting mergePR for PR #${prNumber} in ${repo}`);
448
449 // Proceed with merge
450 const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/merge`;
451 console.log("๐Ÿ” Sending merge request to:", url);
452
468 body: mergeBody,
469 });
470 console.log("๐Ÿ” Merge API response received");
471 console.log("๐Ÿ” Response status:", response.status);
472 console.log("๐Ÿ” Response status text:", response.statusText);
638 body: JSON.stringify(message),
639 });
640 console.log("๐Ÿ” Slack API response received");
641 console.log("๐Ÿ” Response status:", response.status);
642 console.log("๐Ÿ” Response status text:", response.statusText);
649
650 if (!response.ok) {
651 console.error(`โŒ Slack API error: ${response.status} ${response.statusText}`);
652
653 let errorText;
654 try {
655 errorText = await response.text();
656 console.error("โŒ Slack API error response:", errorText);
657 } catch (e) {
658 console.error("โŒ Could not read error response:", e);
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 }
GitHub-PR-Automation

GitHub-PR-Automationgithub-pr-title-prefix.ts5 matches

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

realtimemain.js5 matches

@emarrefโ€ขUpdated 13 hours ago
5// โ—โ—โ— DO NOT USE YOUR TOKEN IN THE BROWSER FOR PRODUCTION. It should be kept and used server-side.
6const APP_TOKEN = process.env.APP_TOKEN;
7// We'll use this for authentication when making requests to the Calls API.
8const headers = {
9 Authorization: `Bearer ${APP_TOKEN}`,
10};
11const API_BASE = `https://rtc.live.cloudflare.com/v1/apps/${APP_ID}`;
12
13const echoMagic = crypto.randomUUID();
21
22const channel1resp = await fetch(
23 `${API_BASE}/sessions/${session1.sessionId}/datachannels/new`,
24 {
25 method: "POST",
45
46const channel1SubscribeResp = await fetch(
47 `${API_BASE}/sessions/${session2.sessionId}/datachannels/new`,
48 {
49 method: "POST",
136 );
137 const { sessionId, sessionDescription } = await fetch(
138 `${API_BASE}/sessions/new`,
139 {
140 method: "POST",

blob_adminmain.tsx6 matches

@wolfโ€ขUpdated 14 hours ago
14
15// Public route without authentication
16app.get("/api/public/:id", async (c) => {
17 const key = `__public/${c.req.param("id")}`;
18 const { blob } = await import("https://esm.town/v/std/blob");
132};
133
134app.get("/api/blobs", checkAuth, async (c) => {
135 const prefix = c.req.query("prefix") || "";
136 const limit = parseInt(c.req.query("limit") || "20", 10);
141});
142
143app.get("/api/blob", checkAuth, async (c) => {
144 const key = c.req.query("key");
145 if (!key) return c.text("Missing key parameter", 400);
149});
150
151app.put("/api/blob", checkAuth, async (c) => {
152 const key = c.req.query("key");
153 if (!key) return c.text("Missing key parameter", 400);
158});
159
160app.delete("/api/blob", checkAuth, async (c) => {
161 const key = c.req.query("key");
162 if (!key) return c.text("Missing key parameter", 400);
166});
167
168app.post("/api/blob", checkAuth, async (c) => {
169 const { file, key } = await c.req.parseBody();
170 if (!file || !key) return c.text("Missing file or key", 400);

blob_adminapp.tsx19 matches

@wolfโ€ขUpdated 14 hours ago
70 const menuRef = useRef(null);
71 const isPublic = blob.key.startsWith("__public/");
72 const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
73
74 useEffect(() => {
234 setLoading(true);
235 try {
236 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
237 const data = await response.json();
238 setBlobs(data);
261 setBlobContentLoading(true);
262 try {
263 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
264 const content = await response.text();
265 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
275 const handleSave = async () => {
276 try {
277 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
278 method: "PUT",
279 body: editContent,
287 const handleDelete = async (key) => {
288 try {
289 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
290 setBlobs(blobs.filter(b => b.key !== key));
291 if (selectedBlob && selectedBlob.key === key) {
304 const key = `${searchPrefix}${file.name}`;
305 formData.append("key", encodeKey(key));
306 await fetch("/api/blob", { method: "POST", body: formData });
307 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
308 setBlobs([newBlob, ...blobs]);
326 try {
327 const fullKey = `${searchPrefix}${key}`;
328 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
329 method: "PUT",
330 body: "",
341 const handleDownload = async (key) => {
342 try {
343 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
344 const blob = await response.blob();
345 const url = window.URL.createObjectURL(blob);
360 if (newKey && newKey !== oldKey) {
361 try {
362 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
363 const content = await response.blob();
364 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
365 method: "PUT",
366 body: content,
367 });
368 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
369 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
370 if (selectedBlob && selectedBlob.key === oldKey) {
380 const newKey = `__public/${key}`;
381 try {
382 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
383 const content = await response.blob();
384 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
385 method: "PUT",
386 body: content,
387 });
388 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
389 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
390 if (selectedBlob && selectedBlob.key === key) {
399 const newKey = key.slice(9); // Remove "__public/" prefix
400 try {
401 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
402 const content = await response.blob();
403 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
404 method: "PUT",
405 body: content,
406 });
407 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
408 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
409 if (selectedBlob && selectedBlob.key === key) {
554 onClick={() =>
555 copyToClipboard(
556 `${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
557 )}
558 className="text-blue-400 hover:text-blue-300 text-sm"
577 >
578 <img
579 src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
580 alt="Blob content"
581 className="max-w-full h-auto"

gptApiTemplate2 file matches

@charmaineโ€ขUpdated 1 day ago

mod-interview-api1 file match

@twschillerโ€ขUpdated 1 day ago
aquapi
apiv1