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=340&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 9556 results for "api"(1641ms)

vtProjectSearchweb.http.tsx1 match

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

vtProjectSearchstyles.tsx4 matches

@stevekrouse•Updated 3 weeks ago
753}
754
755.api-info {
756 margin-top: 10px;
757}
758
759.api-info summary {
760 cursor: pointer;
761 color: var(--primary-color);
763}
764
765.api-docs {
766 background-color: var(--code-bg);
767 padding: 10px 15px;
772}
773
774.api-docs code {
775 display: inline-block;
776 background-color: white;

vtProjectSearchimport.ts1 match

@stevekrouse•Updated 3 weeks ago
37 profile_image_url: user.profileImageUrl,
38 url: user.url,
39 updated_at: new Date().toISOString(), // Using current time as the API doesn't provide updated_at
40 });
41

vtProjectSearchdeno.lock2 matches

@stevekrouse•Updated 3 weeks ago
363 },
364 "redirects": {
365 "https://esm.town/v/std/API_URL": "https://esm.town/v/std/API_URL?v=5",
366 "https://esm.town/v/stevekrouse/sqlite": "https://esm.town/v/stevekrouse/sqlite?v=13"
367 },
368 "remote": {
369 "https://docs.val.town/pagefind/pagefind.js": "43ee232b23e27fa6b00d4f71f08a165d35a824947525989c7a051843e408e0c0",
370 "https://esm.town/v/std/API_URL?v=5": "46109f905a50e32281d3ffbe7b9c8209a778290c5274d83d131fba2d26c4974d",
371 "https://esm.town/v/stevekrouse/sqlite?v=13": "3b613197e9da35db335dc2726c062c61f9247439c10a0c64c118994e200ffa46"
372 }

vtProjectSearchcomponents.tsx8 matches

@stevekrouse•Updated 3 weeks ago
1062 <link rel="icon" href="https://fav.farm/👀" />
1063 <meta name="viewport" content="width=device-width, initial-scale=1" />
1064 <link rel="preconnect" href="https://fonts.googleapis.com" />
1065 <link rel="preconnect" href="https://fonts.gstatic.com" crossOrigin="anonymous" />
1066 <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&display=swap" rel="stylesheet" />
1067 <style>
1068 {styles}
1073 <div className="header">
1074 <h1><a href="/" className="title-link">Val Town Code Search</a><a href="https://val.town" className="valtown-link" style={{ marginLeft: 'auto' }} >Return to Val Town</a></h1>
1075 <div className="api-info">
1076 <details>
1077 <summary>API Access</summary>
1078 <div className="api-docs">
1079 <p>You can access search results via JSON API by adding <code>format=json</code> to your query:</p>
1080 {searchTerm ? (
1081 <a href={`?q=${encodeURIComponent(searchTerm)}&page=${currentPage}&format=json`} target="_blank">
1210 <div className="search-examples">
1211 <a href="?q=fetch" className="example-link">fetch</a>
1212 <a href="?q=api" className="example-link">api</a>
1213 <a href="?q=database" className="example-link">database</a>
1214 <a href="?q=image" className="example-link">image</a>
1355 <div className="search-examples">
1356 <a href="?q=fetch" className="example-link">fetch</a>
1357 <a href="?q=api" className="example-link">api</a>
1358 <a href="?q=database" className="example-link">database</a>
1359 <a href="?q=image" className="example-link">image</a>

vtProjectSearchapi.tsx2 matches

@stevekrouse•Updated 3 weeks 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 }

stevensindex.ts11 matches

@geoffreylitt•Updated 3 weeks ago
26});
27
28// --- API Routes for Memories ---
29
30// GET /api/memories - Retrieve all memories
31app.get("/api/memories", async (c) => {
32 const memories = await getAllMemories();
33 return c.json(memories);
34});
35
36// POST /api/memories - Create a new memory
37app.post("/api/memories", async (c) => {
38 const body = await c.req.json<Omit<Memory, "id">>();
39 if (!body.text) {
44});
45
46// PUT /api/memories/:id - Update an existing memory
47app.put("/api/memories/:id", async (c) => {
48 const id = c.req.param("id");
49 const body = await c.req.json<Partial<Omit<Memory, "id">>>();
66});
67
68// DELETE /api/memories/:id - Delete a memory
69app.delete("/api/memories/:id", async (c) => {
70 const id = c.req.param("id");
71 try {
83// --- Blob Image Serving Routes ---
84
85// GET /api/images/:filename - Serve images from blob storage
86app.get("/api/images/:filename", async (c) => {
87 const filename = c.req.param("filename");
88

blob_adminmain.tsx25 matches

@geoffreylitt•Updated 3 weeks ago
73 const menuRef = useRef(null);
74 const isPublic = blob.key.startsWith("__public/");
75 const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
76
77 useEffect(() => {
237 setLoading(true);
238 try {
239 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
240 const data = await response.json();
241 setBlobs(data);
264 setBlobContentLoading(true);
265 try {
266 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
267 const content = await response.text();
268 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
278 const handleSave = async () => {
279 try {
280 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
281 method: "PUT",
282 body: editContent,
290 const handleDelete = async (key) => {
291 try {
292 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
293 setBlobs(blobs.filter(b => b.key !== key));
294 if (selectedBlob && selectedBlob.key === key) {
307 const key = `${searchPrefix}${file.name}`;
308 formData.append("key", encodeKey(key));
309 await fetch("/api/blob", { method: "POST", body: formData });
310 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
311 setBlobs([newBlob, ...blobs]);
329 try {
330 const fullKey = `${searchPrefix}${key}`;
331 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
332 method: "PUT",
333 body: "",
344 const handleDownload = async (key) => {
345 try {
346 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
347 const blob = await response.blob();
348 const url = window.URL.createObjectURL(blob);
363 if (newKey && newKey !== oldKey) {
364 try {
365 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
366 const content = await response.blob();
367 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
368 method: "PUT",
369 body: content,
370 });
371 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
372 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
373 if (selectedBlob && selectedBlob.key === oldKey) {
383 const newKey = `__public/${key}`;
384 try {
385 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
386 const content = await response.blob();
387 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
388 method: "PUT",
389 body: content,
390 });
391 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
392 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
393 if (selectedBlob && selectedBlob.key === key) {
402 const newKey = key.slice(9); // Remove "__public/" prefix
403 try {
404 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
405 const content = await response.blob();
406 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
407 method: "PUT",
408 body: content,
409 });
410 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
411 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
412 if (selectedBlob && selectedBlob.key === key) {
557 onClick={() =>
558 copyToClipboard(
559 `${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
560 )}
561 className="text-blue-400 hover:text-blue-300 text-sm"
580 >
581 <img
582 src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
583 alt="Blob content"
584 className="max-w-full h-auto"
660
661// Public route without authentication
662app.get("/api/public/:id", async (c) => {
663 const key = `__public/${c.req.param("id")}`;
664 const { blob } = await import("https://esm.town/v/std/blob");
778};
779
780app.get("/api/blobs", checkAuth, async (c) => {
781 const prefix = c.req.query("prefix") || "";
782 const limit = parseInt(c.req.query("limit") || "20", 10);
787});
788
789app.get("/api/blob", checkAuth, async (c) => {
790 const key = c.req.query("key");
791 if (!key) return c.text("Missing key parameter", 400);
795});
796
797app.put("/api/blob", checkAuth, async (c) => {
798 const key = c.req.query("key");
799 if (!key) return c.text("Missing key parameter", 400);
804});
805
806app.delete("/api/blob", checkAuth, async (c) => {
807 const key = c.req.query("key");
808 if (!key) return c.text("Missing key parameter", 400);
812});
813
814app.post("/api/blob", checkAuth, async (c) => {
815 const { file, key } = await c.req.parseBody();
816 if (!file || !key) return c.text("Missing file or key", 400);

stevensREADME.md5 matches

@geoffreylitt•Updated 3 weeks ago
8## Hono
9
10This app uses [Hono](https://hono.dev/) as the API framework. You can think of Hono as a replacement for [ExpressJS](https://expressjs.com/) that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like [Flask](https://github.com/pallets/flask) or [Sinatra](https://github.com/sinatra/sinatra), respectively.
11
12## Serving assets to the frontend
20### `index.html`
21
22The most complicated part of this backend API is serving index.html. In this app (like most apps) we serve it at the root, ie `GET /`.
23
24We *bootstrap* `index.html` with some initial data from the server, so that it gets dynamically injected JSON data without having to make another round-trip request to the server to get that data on the frontend. This is a common pattern for client-side rendered apps.
25
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors
31
32Hono and other API frameworks have a habit of swallowing up Errors. We turn off this default behavior by re-throwing errors, because we think most of the time you'll want to see the full stack trace instead of merely "Internal Server Error". You can customize how you want errors to appear.

reactHonoExampleREADME.md5 matches

@geoffreylitt•Updated 3 weeks ago
8## Hono
9
10This app uses [Hono](https://hono.dev/) as the API framework. You can think of Hono as a replacement for [ExpressJS](https://expressjs.com/) that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like [Flask](https://github.com/pallets/flask) or [Sinatra](https://github.com/sinatra/sinatra), respectively.
11
12## Serving assets to the frontend
20### `index.html`
21
22The most complicated part of this backend API is serving index.html. In this app (like most apps) we serve it at the root, ie `GET /`.
23
24We *bootstrap* `index.html` with some initial data from the server, so that it gets dynamically injected JSON data without having to make another round-trip request to the server to get that data on the frontend. This is a common pattern for client-side rendered apps.
25
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors
31
32Hono and other API frameworks have a habit of swallowing up Errors. We turn off this default behavior by re-throwing errors, because we think most of the time you'll want to see the full stack trace instead of merely "Internal Server Error". You can customize how you want errors to appear.

daily-advice-app1 file match

@dcm31•Updated 1 day ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaine•Updated 2 days ago
api
aquapi