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=509&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 10293 results for "api"(3191ms)

blob_admin_migratedmain.tsx25 matches

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

sqliteExplorerAppREADME.md1 match

@shouserUpdated 2 months ago
13## Authentication
14
15Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
16
17## Todos / Plans

sqliteExplorerAppmain.tsx2 matches

@shouserUpdated 2 months ago
27 <head>
28 <title>SQLite Explorer</title>
29 <link rel="preconnect" href="https://fonts.googleapis.com" />
30
31 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32 <link
33 href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34 rel="stylesheet"
35 />

versatileWhiteJaymain.tsx7 matches

@LoveUpdated 2 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5// TMDB API Configuration
6const TMDB_API_KEY = "3fd2be6f0c70a2a598f084ddfb75487c"; // Public read-only key
7const TMDB_BASE_URL = "https://api.themoviedb.org/3";
8const TMDB_IMAGE_BASE_URL = "https://image.tmdb.org/t/p/w500";
9
45 async () => {
46 const response = await fetch(
47 `${TMDB_BASE_URL}/search/person?api_key=${TMDB_API_KEY}&query=${encodeURIComponent(searchTerm)}&language=en-US&page=1`
48 );
49 const data = await response.json();
54 const alternativeSearches = INDIAN_FILM_KEYWORDS.map(async (keyword) => {
55 const response = await fetch(
56 `${TMDB_BASE_URL}/search/person?api_key=${TMDB_API_KEY}&query=${encodeURIComponent(`${searchTerm} ${keyword}`)}&language=en-US&page=1`
57 );
58 const data = await response.json();
108 async () => {
109 const response = await fetch(
110 `${TMDB_BASE_URL}/person/${actorId}/movie_credits?api_key=${TMDB_API_KEY}&language=en-US`
111 );
112 const data = await response.json();
118 INDIAN_LANGUAGES.map(async (lang) => {
119 const response = await fetch(
120 `${TMDB_BASE_URL}/discover/movie?api_key=${TMDB_API_KEY}&with_cast=${actorId}&with_original_language=${lang}&sort_by=popularity.desc`
121 );
122 const data = await response.json();

CRMmain.tsx1 match

@juecdUpdated 2 months ago
835 <head>
836 <title>🌽 Kernel CRM</title>
837 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
838 <style>${css}</style>
839 <meta name="viewport" content="width=device-width, initial-scale=1" />

OpenTownieREADME.md3 matches

@AIWBUpdated 2 months ago
10## Getting Started
11
121. Create a [Val Town API token](https://www.val.town/settings/api) with Val read and write permissions
132. Paste the token into the input box and get started
14
15## Forking the Project
16
17You'll need to get an **Open Router API key**.
18We choose Open Router so we could easily switch between
19all models. We soon want to make it so you can choose your
20model from a dropdown, but we're having trouble formatting the api calls such that they work on all providers. Maybe we need to switch to the vercel sdk

OpenTowniesystem_prompt.txt2 matches

@AIWBUpdated 2 months ago
26 * DO NOT use the alert(), prompt(), or confirm() methods.
27
28 * If the user's app needs weather data, use open-meteo unless otherwise specified because it doesn't require any API keys.
29
30 * Tastefully add a view source link back to the user's val if there's a natural spot for it. Generate the val source url via `import.meta.url.replace("esm.town", "val.town")`. This link element should include a target="_top" attribute.
38 Val Town's client-side catch script automatically catches client-side errors to aid in debugging.
39
40 * Don't use any environment variables unless strictly necessary. For example use APIs that don't require a key.
41 If you need environment variables use `Deno.env.get('keyname')`
42

OpenTowniegenerateCode2 matches

@AIWBUpdated 2 months ago
29
30 const openai = new OpenAI({
31 baseURL: "https://openrouter.ai/api/v1",
32 apiKey: Deno.env.get("OPEN_ROUTER_KEY"),
33 });
34 console.log(messages);

ThumbMakermain.tsx1 match

@AIWBUpdated 2 months ago
2 * This application creates a thumbnail maker using Hono for server-side routing and client-side JavaScript for image processing.
3 * It allows users to upload images, specify output options, and generate a composite thumbnail image.
4 * The app uses the HTML5 Canvas API for image manipulation and supports drag-and-drop functionality.
5 *
6 * The process is divided into two steps:

createWebsitemain.tsx5 matches

@Mostafa3135Updated 2 months ago
4
5// Utility Functions
6const API_BASE_URL = 'https://api.example.com';
7
8// Components
68 e.preventDefault();
69 try {
70 const response = await fetch(`${API_BASE_URL}/login`, {
71 method: 'POST',
72 headers: { 'Content-Type': 'application/json' },
121
122 try {
123 const response = await fetch(`${API_BASE_URL}/signup`, {
124 method: 'POST',
125 headers: { 'Content-Type': 'application/json' },
181
182 try {
183 const response = await fetch(`${API_BASE_URL}/upload`, {
184 method: 'POST',
185 body: formData
215
216 try {
217 const response = await fetch(`${API_BASE_URL}/chat`, {
218 method: 'POST',
219 headers: { 'Content-Type': 'application/json' },

daily-advice-app1 file match

@dcm31Updated 1 day ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaineUpdated 2 days ago
papimark21
socialdata
Affordable & reliable alternative to Twitter API: ➡️ Access user profiles, tweets, followers & timeline data in real-time ➡️ Monitor profiles with nearly instant alerts for new tweets, follows & profile updates ➡️ Simple integration