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/$1?q=api&page=1382&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 18131 results for "api"(2409ms)

SermonGPTUImain.tsx2 matches

@manyone•Updated 6 months ago
76}
77
78const endpointURL = "https://mjweaver01-sermongptapi.web.val.run";
79
80function App() {
642 <title>Sermon Generator</title>
643 <style>
644 @import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@300;400;500&display=swap');
645 body {
646 font-family: 'Roboto', sans-serif;

legendaryRoseSwordfishmain.tsx10 matches

@ronr•Updated 6 months ago
20
21 const fetchData = async () => {
22 const response = await fetch("/api/data");
23 const data = await response.json();
24 setParticipants(data.participants);
28 const handleLogin = async (e) => {
29 e.preventDefault();
30 const response = await fetch("/api/login", {
31 method: "POST",
32 headers: { "Content-Type": "application/json" },
49 const handleSubmit = async (e) => {
50 e.preventDefault();
51 const response = await fetch("/api/update", {
52 method: "POST",
53 headers: { "Content-Type": "application/json" },
64 const handleReset = async () => {
65 if (window.confirm("Are you sure you want to reset all points?")) {
66 const response = await fetch("/api/reset", { method: "POST" });
67 if (response.ok) {
68 fetchData();
72
73 const handleExportCSV = async () => {
74 const response = await fetch("/api/export-csv");
75 const blob = await response.blob();
76 const url = window.URL.createObjectURL(blob);
248 `);
249
250 if (req.method === "POST" && req.url.endsWith("/api/login")) {
251 const { username, password } = await req.json();
252 if (username === "admin" && password === "123123123") {
256 }
257
258 if (req.method === "POST" && req.url.endsWith("/api/update")) {
259 const { name, points, note } = await req.json();
260 await sqlite.execute(
276 }
277
278 if (req.method === "POST" && req.url.endsWith("/api/reset")) {
279 await sqlite.execute(`DELETE FROM ${KEY}_participants_${SCHEMA_VERSION}`);
280 await sqlite.execute(`DELETE FROM ${KEY}_logs_${SCHEMA_VERSION}`);
282 }
283
284 if (req.url.endsWith("/api/data")) {
285 const participants = await sqlite.execute(`
286 SELECT * FROM ${KEY}_participants_${SCHEMA_VERSION}
303 }
304
305 if (req.url.endsWith("/api/export-csv")) {
306 const participants = await sqlite.execute(`
307 SELECT * FROM ${KEY}_participants_${SCHEMA_VERSION}

SermonGPTAPIREADME.md1 match

@mjweaver01•Updated 6 months ago
1Migrated from folder: SermonGPT/SermonGPTAPI

blob_adminmain.tsx25 matches

@dakota•Updated 6 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);

whoIsHiringmain.tsx4 matches

@dxaginfo•Updated 6 months ago
63 const fetchStories = async () => {
64 try {
65 const response = await fetch("/api/stories");
66 if (!response.ok) throw new Error("Failed to fetch dates");
67 const data = await response.json();
77 try {
78 dispatch({ type: "loading", value: true });
79 const response = await fetch(`/api/comments?query=${encodeURIComponent(query)}&story=${story}&page=${page}`);
80 if (!response.ok) throw new Error("Failed to fetch comments");
81 const data = await response.json();
360export default async function(req: Request): Promise<Response> {
361 const url = new URL(req.url);
362 if (url.pathname === "/api/stories") {
363 const storySearch = await hnSearch({
364 search_by_date: true,
381 }
382
383 if (url.pathname === "/api/comments") {
384 const params = url.searchParams;
385 const query = params.get("query") || "";

lazyCookmain.tsx1 match

@dxaginfo•Updated 6 months ago
265
266 if (!jsonContent) {
267 throw new Error("Failed to extract JSON from the API response");
268 }
269

savvyTealCardinalmain.tsx12 matches

@dxaginfo•Updated 6 months ago
405
406const css = `
407 @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap');
408
409 :root {
737async function server(request: Request): Promise<Response> {
738 if (request.method === "POST" && new URL(request.url).pathname === "/generate-training") {
739 const YOUTUBE_API_KEY = Deno.env.get("YOUTUBE_API_KEY2");
740 const useApiKey = YOUTUBE_API_KEY !== undefined && YOUTUBE_API_KEY !== "";
741 if (!YOUTUBE_API_KEY) {
742 console.warn("YouTube API key (YOUTUBE_API_KEY2) is not set. Falling back to search URL method.");
743 }
744
805 for (const placeholder of videoPlaceholders) {
806 const searchQuery = placeholder.replace("[VIDEO: ", "").replace("]", "");
807 const videoId = await getYouTubeVideoId(searchQuery, sport, YOUTUBE_API_KEY);
808 if (videoId) {
809 const embedHtml = `
891}
892
893async function getYouTubeVideoId(query, sport, apiKey, useApiKey = true) {
894 if (useApiKey) {
895 try {
896 const searchUrl = `https://www.googleapis.com/youtube/v3/search?part=snippet&q=${
897 encodeURIComponent(sport + " " + query)
898 }&key=${apiKey}&type=video&maxResults=1`;
899 const response = await fetch(searchUrl);
900 const data = await response.json();
901 if (data.error) {
902 console.warn("YouTube API error:", data.error.message);
903 return getFallbackYouTubeLink(query, sport);
904 }
907 }
908 } catch (error) {
909 console.error("Error fetching from YouTube API:", error);
910 }
911 }

versatileBrownClownfishmain.tsx1 match

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

bandcampWrappedmain.tsx4 matches

@tmcw•Updated 6 months ago
77
78<p>
79 Spotify <a href='https://www.theverge.com/2024/12/5/24311523/spotify-locked-down-apis-developers'>does</a>
80 a <a href='https://www.theverge.com/2024/11/14/24294995/spotify-ai-fake-albums-scam-distributors-metadata'>lot</a>
81 of <a href='https://www.vice.com/en/article/spotify-rogan-rfk-vaccine-misinformation-policy/'>bad</a>
92 needlessly complex because, like way too many companies,
93 Bandcamp has <a href='https://www.reddit.com/r/BandCamp/comments/k8ojd2/question_for_any_devs_with_bandcamp_experience/'>locked down</a>
94 and <a href='https://github.com/michaelherger/Bandcamp-API'>hobbled</a> their public
95 API, probably because bad actors would abuse it, which is reasonable, but
96 on the other hand, made it impossible to do creative things like this that benefit
97 Bandcamp without annoying workarounds. I don't know, people would probably
98 <a href='https://www.404media.co/bluesky-posts-machine-learning-ai-datasets-hugging-face/'>
99 train some large language model on Bandcamp data</a> if there was a public API,
100 because that's what people do now.
101</p>

bandcampWrappedREADME.md2 matches

@tmcw•Updated 6 months ago
5wacky enough to buy their music instead of streaming it from some service.
6
7Because Bandcamp doesn't have an API, this hinges on you going to your purchases page, copying the purchases, and pasting it in. Thanks to
8the ability of [the system clipboard to contain HTML](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem), the same technology that makes
9copy-and-pasted text have unpredictable and annoying font and boldness choices also lets this parse and reformat that purchases page into something
10shareable.

xxxclearinghouse_validator

@toowired•Updated 2 hours ago
Request validator for clearance API

Apiify11 file matches

@wolf•Updated 20 hours ago
Kapil01
apiv1