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=589&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 8532 results for "api"(716ms)

glifInventorymain.tsx1 match

@jamiedubs•Updated 5 months ago
371 <h1>🎒 Inventory Management System</h1>
372
373 <h2>API Routes</h2>
374
375 <h3 class="route">GET /inventory</h3>

blob_adminmain.tsx25 matches

@cameronpak•Updated 5 months 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");
765};
766
767app.get("/api/blobs", checkAuth, async (c) => {
768 const prefix = c.req.query("prefix") || "";
769 const limit = parseInt(c.req.query("limit") || "20", 10);
774});
775
776app.get("/api/blob", checkAuth, async (c) => {
777 const key = c.req.query("key");
778 if (!key) return c.text("Missing key parameter", 400);
782});
783
784app.put("/api/blob", checkAuth, async (c) => {
785 const key = c.req.query("key");
786 if (!key) return c.text("Missing key parameter", 400);
791});
792
793app.delete("/api/blob", checkAuth, async (c) => {
794 const key = c.req.query("key");
795 if (!key) return c.text("Missing key parameter", 400);
799});
800
801app.post("/api/blob", checkAuth, async (c) => {
802 const { file, key } = await c.req.parseBody();
803 if (!file || !key) return c.text("Missing file or key", 400);

zanySalmonPorpoisemain.tsx1 match

@anhv_12•Updated 5 months ago
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
8 return response.json();

blob_adminmain.tsx25 matches

@eowczarek•Updated 5 months 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");
765};
766
767app.get("/api/blobs", checkAuth, async (c) => {
768 const prefix = c.req.query("prefix") || "";
769 const limit = parseInt(c.req.query("limit") || "20", 10);
774});
775
776app.get("/api/blob", checkAuth, async (c) => {
777 const key = c.req.query("key");
778 if (!key) return c.text("Missing key parameter", 400);
782});
783
784app.put("/api/blob", checkAuth, async (c) => {
785 const key = c.req.query("key");
786 if (!key) return c.text("Missing key parameter", 400);
791});
792
793app.delete("/api/blob", checkAuth, async (c) => {
794 const key = c.req.query("key");
795 if (!key) return c.text("Missing key parameter", 400);
799});
800
801app.post("/api/blob", checkAuth, async (c) => {
802 const { file, key } = await c.req.parseBody();
803 if (!file || !key) return c.text("Missing file or key", 400);

EnkakuStatefulHTTPExampleClientREADME.md1 match

@paul_lecam•Updated 5 months ago
1Example of an [Enkaku client](https://enkaku.dev/docs/api/client/) using HTTP.
2
3[Server code Val](https://www.val.town/v/paul_lecam/EnkakuStatefulHTTPExample)

EnkakuStatefulHTTPExampleREADME.md1 match

@paul_lecam•Updated 5 months ago
1Example of an [Enkaku server](https://enkaku.dev/docs/api/server/) over HTTP.
2
3[Client code Val](https://www.val.town/v/paul_lecam/EnkakuStatefulHTTPExampleClient)

exaltedAmethystAntelopeREADME.md1 match

@dcm31•Updated 5 months ago
3The app is set up so you can easily have a conversation between two people. The app will translate between the two selected languages, in each voice, as the speakers talk.
4
5Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.

exaltedAmethystAntelopemain.tsx4 matches

@dcm31•Updated 5 months ago
6
7const app = new Hono();
8const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY_VOICE"));
9
10class TranscriptionService {
19 return transcription;
20 } catch (error) {
21 console.error("OpenAI API error:", error);
22 throw error;
23 }
423 return c.text(translation);
424 } catch (error) {
425 console.error("OpenAI API error:", error);
426 return c.text("Error occurred during translation", 500);
427 }
450 });
451 } catch (error) {
452 console.error("OpenAI API error:", error);
453 return c.text("Error occurred during speech generation", 500);
454 }

translatorREADME.md1 match

@dcm31•Updated 5 months ago
3The app is set up so you can easily have a conversation between two people. The app will translate between the two selected languages, in each voice, as the speakers talk.
4
5Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.

translatormain.tsx4 matches

@dcm31•Updated 5 months ago
5
6const app = new Hono();
7const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY_VOICE"));
8
9class TranscriptionService {
18 return transcription;
19 } catch (error) {
20 console.error('OpenAI API error:', error);
21 throw error;
22 }
368 return c.text(translation);
369 } catch (error) {
370 console.error('OpenAI API error:', error);
371 return c.text('Error occurred during translation', 500);
372 }
395 });
396 } catch (error) {
397 console.error('OpenAI API error:', error);
398 return c.text('Error occurred during speech generation', 500);
399 }

daily-advice-app1 file match

@dcm31•Updated 21 hours ago
Random advice app using Advice Slip API

runValAPIEx2 file matches

@charmaine•Updated 1 day ago
substrate
Substrate is the modular API for fast multi-step AI programs
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)