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=993&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 17382 results for "api"(1724ms)

blob_adminnapp.tsx19 matches

@charmaine•Updated 1 month 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"

quotesmain.tsx6 matches

@alice791s•Updated 1 month ago
1475
1476 // Get random quote
1477 if (url.pathname === "/api/quote/random" && request.method === "GET") {
1478 const randomIndex = Math.floor(Math.random() * quotes.length);
1479 const quote = quotes[randomIndex];
1490
1491 // Get quote by index
1492 if (url.pathname.startsWith("/api/quote/") && request.method === "GET") {
1493 const index = parseInt(url.pathname.split("/").pop());
1494 const quote = quotes.find(q => q.index === index);
1515
1516 // Get quotes by tag
1517 if (url.pathname === "/api/quote/tag" && request.method === "GET") {
1518 const tag = url.searchParams.get("tag");
1519
1543
1544 // Get quotes by author
1545 if (url.pathname === "/api/quote/author" && request.method === "GET") {
1546 const author = url.searchParams.get("author");
1547
1569
1570 // Get top quotes by likes
1571 if (url.pathname === "/api/quote/top" && request.method === "GET") {
1572 const limit = parseInt(url.searchParams.get("limit") || "10");
1573
1587
1588 // Search quotes
1589 if (url.pathname === "/api/quote/search" && request.method === "GET") {
1590 const query = url.searchParams.get("q");
1591

reactHonoStarterDupeSTART_HERE.ts3 matches

@charmaine•Updated 1 month ago
8import { serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
9import { Hono } from "npm:hono";
10import { addApiRoutes } from "./api.ts";
11import type { OnboardingSettings } from "./state.ts"; // Import type for clarity
12import { addTrackerRoute } from "./trackerRoute.ts";
72addTrackerRoute(app);
73
74// 2. Add API endpoints used by the tracker (reset, etc.)
75addApiRoutes(app);
76
77// 3. Serve static files from the /frontend directory (if you add any)

reactHonoStarterDupescheduledEmailDemo.ts2 matches

@charmaine•Updated 1 month ago
4const ideas = [
5 "a URL shortener",
6 "a custom API for your personal website",
7 "a weather notification bot",
8 "a tool to monitor website uptime",
10 "a simple webhook processor",
11 "a daily joke emailer",
12 "a personal habit tracker API",
13 "a stock price alerter",
14 "a meeting reminder service",

reactHonoStarterDupestate.ts1 match

@charmaine•Updated 1 month ago
18
19const STATE_KEY = "onboardingProgressState_v2"; // Key for blob-managed state
20const SETTINGS_OVERRIDE_KEY = "onboardingSettingsOverrides_v1"; // Optional: if you want to allow API overrides
21
22// --- Settings Management ---

reactHonoStarterDupeapi.ts3 matches

@charmaine•Updated 1 month ago
4
5/**
6 * Adds API routes (/api/...) to the Hono app.
7 */
8export function addApiRoutes(app: Hono) {
9 // Endpoint to reset onboarding progress and settings
10 app.post("/api/reset", async (c: Context) => {
11 try {
12 await resetOnboardingState(); // This now resets settings too

reactHonoStarterDupetracker.html5 matches

@charmaine•Updated 1 month ago
80 </div>
81 <!-- Right Actions -->
82 <button class="reset-button" onclick="if(confirm('Reset progress flags in START_HERE.ts? (You may need to manually edit the file)')) postApi('/api/reset').then(()=>window.location.reload())" title="Reset onboarding state (clears blob state)">Reset</button>
83 </div>
84 </div>
85 <script>
86 // Helper function for API calls
87 async function postApi(endpoint) {
88 try {
89 const response = await fetch(endpoint, { method: 'POST' });
90 if (!response.ok) {
91 throw new Error(`API Error: ${response.statusText}`);
92 }
93 return await response.json();
94 } catch (error) {
95 console.error('API call failed:', error);
96 alert('Operation failed: ' + error.message);
97 }

reactHonoStarterDupetrackerRoute.ts6 matches

@charmaine•Updated 1 month ago
11} from "./state.ts";
12
13// Define API routes separately for clarity
14const api = new Hono();
15api.post("/reset", async (c) => {
16 await resetOnboardingState();
17 console.log("Onboarding state reset via API.");
18 return c.json({ success: true, message: "Onboarding reset" });
19});
20
21export function addTrackerRoute(app: Hono) {
22 // Mount API routes
23 app.route("/api", api);
24
25 app.get("/", async (c: Context) => {
vtProjectSearch

vtProjectSearchweb.http.tsx1 match

@maxm•Updated 1 month ago
1import { handler } from "./api.tsx";
2import { loadTypeaheadDataIntoMemory } from "./db.ts";
3
vtProjectSearch

vtProjectSearchapi.tsx2 matches

@maxm•Updated 1 month ago
13import { searchDocs, searchDocsCount } from "./docsearch.ts";
14
15// Handle typeahead API requests
16export function handleTypeahead(req: Request): Response {
17 const url = new URL(req.url);
99 searchTerm
100 ? (needFullDocsData
101 ? searchDocs(searchTerm, page, pageSize, true) // Get full data for docs tab or JSON API
102 : searchDocsCount(searchTerm).then(count => ({ results: [], totalResults: count }))) // Just get count for other tabs in HTML view
103 : { results: [], totalResults: 0 }

RandomQuoteAPI

@Freelzy•Updated 3 hours ago

HAPI7 file matches

@dIgitalfulus•Updated 9 hours ago
Kapil01
apiv1