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/$%7Bsuccess?q=api&page=975&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 13896 results for "api"(1649ms)

firehosemain.tsx3 matches

@stevekrouse•Updated 6 months ago
1/** @jsxImportSource https://esm.sh/react */
2import { AtpAgent } from "https://esm.sh/@atproto/api@0.13.15";
3import { AnimatePresence, motion } from "https://esm.sh/framer-motion";
4import React, { useEffect, useMemo, useRef, useState } from "https://esm.sh/react";
6import { TagCloud } from "https://esm.sh/react-tagcloud@2.2.0";
7
8const service = "https://public.api.bsky.app";
9const agent = new AtpAgent({ service });
10
250 </script>
251 <style>
252 @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');
253 body {
254 font-family: 'Inter', sans-serif;

blob_adminmain.tsx26 matches

@steveVT•Updated 6 months ago
72 const menuRef = useRef(null);
73 const isPublic = blob.key.startsWith("__public/");
74 const publicUrl = isPublic ? `${window.location.origin}/api/public/${encodeURIComponent(blob.key.slice(9))}` : null;
75
76 useEffect(() => {
236 setLoading(true);
237 try {
238 const response = await fetch(`/api/blobs?prefix=${encodeKey(searchPrefix)}&limit=${limit}`);
239 const data = await response.json();
240 setBlobs(data);
263 setBlobContentLoading(true);
264 try {
265 const response = await fetch(`/api/blob?key=${encodeKey(clickedBlob.key)}`);
266 const content = await response.text();
267 setSelectedBlob({ ...clickedBlob, key: decodeKey(clickedBlob.key) });
277 const handleSave = async () => {
278 try {
279 await fetch(`/api/blob?key=${encodeKey(selectedBlob.key)}`, {
280 method: "PUT",
281 body: editContent,
289 const handleDelete = async (key) => {
290 try {
291 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
292 setBlobs(blobs.filter(b => b.key !== key));
293 if (selectedBlob && selectedBlob.key === key) {
306 const key = `${searchPrefix}${file.name}`;
307 formData.append("key", encodeKey(key));
308 await fetch("/api/blob", { method: "POST", body: formData });
309 const newBlob = { key, size: file.size, lastModified: new Date().toISOString() };
310 setBlobs([newBlob, ...blobs]);
328 try {
329 const fullKey = `${searchPrefix}${key}`;
330 await fetch(`/api/blob?key=${encodeKey(fullKey)}`, {
331 method: "PUT",
332 body: "",
343 const handleDownload = async (key) => {
344 try {
345 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
346 const blob = await response.blob();
347 const url = window.URL.createObjectURL(blob);
362 if (newKey && newKey !== oldKey) {
363 try {
364 const response = await fetch(`/api/blob?key=${encodeKey(oldKey)}`);
365 const content = await response.blob();
366 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
367 method: "PUT",
368 body: content,
369 });
370 await fetch(`/api/blob?key=${encodeKey(oldKey)}`, { method: "DELETE" });
371 setBlobs(blobs.map(b => b.key === oldKey ? { ...b, key: newKey } : b));
372 if (selectedBlob && selectedBlob.key === oldKey) {
382 const newKey = `__public/${key}`;
383 try {
384 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
385 const content = await response.blob();
386 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
387 method: "PUT",
388 body: content,
389 });
390 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
391 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
392 if (selectedBlob && selectedBlob.key === key) {
401 const newKey = key.slice(9); // Remove "__public/" prefix
402 try {
403 const response = await fetch(`/api/blob?key=${encodeKey(key)}`);
404 const content = await response.blob();
405 await fetch(`/api/blob?key=${encodeKey(newKey)}`, {
406 method: "PUT",
407 body: content,
408 });
409 await fetch(`/api/blob?key=${encodeKey(key)}`, { method: "DELETE" });
410 setBlobs(blobs.map(b => b.key === key ? { ...b, key: newKey } : b));
411 if (selectedBlob && selectedBlob.key === key) {
556 onClick={() =>
557 copyToClipboard(
558 `${window.location.origin}/api/public/${encodeURIComponent(selectedBlob.key.slice(9))}`,
559 )}
560 className="text-blue-400 hover:text-blue-300 text-sm"
579 >
580 <img
581 src={`/api/blob?key=${encodeKey(selectedBlob.key)}`}
582 alt="Blob content"
583 className="max-w-full h-auto"
655
656export default lastlogin(async function handler(request: Request): Promise<Response> {
657 if (request.method === "GET" && request.url.includes("/api/public/")) {
658 const url = new URL(request.url);
659 const key = `__public/${decodeURIComponent(url.pathname.split("/api/public/")[1])}`;
660 const { blob } = await import("https://esm.town/v/std/blob");
661 const content = await blob.get(key);
762 }
763
764 if (request.method === "GET" && request.url.includes("/api/blobs")) {
765 const url = new URL(request.url);
766 const prefix = decodeURIComponent(url.searchParams.get("prefix") || "");
774 }
775
776 if (request.method === "GET" && request.url.includes("/api/blob")) {
777 const url = new URL(request.url);
778 const key = decodeURIComponent(url.searchParams.get("key"));
783 }
784
785 if (request.method === "PUT" && request.url.includes("/api/blob")) {
786 const url = new URL(request.url);
787 const key = decodeURIComponent(url.searchParams.get("key"));
793 }
794
795 if (request.method === "DELETE" && request.url.includes("/api/blob")) {
796 const url = new URL(request.url);
797 const key = decodeURIComponent(url.searchParams.get("key"));
802 }
803
804 if (request.method === "POST" && request.url.includes("/api/blob")) {
805 const formData = await request.formData();
806 const file = formData.get("file") as File;

workersmain.tsx1 match

@temptemp•Updated 6 months ago
58}
59async function upload(formData: any, user: string) {
60 const _ = await fetch("https://workers.cloudflare.com/playground/api/worker", {
61 "headers": {
62 ...commonHeaders,

immaculateTanMooseREADME.md1 match

@stevekrouse•Updated 6 months ago
11[![](https://stevekrouse-button.web.val.run/Install)](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
12
13It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
14
15# TODO

ddg_chatmain.tsx6 matches

@kauri•Updated 6 months ago
7import { oneDark } from "https://esm.sh/react-syntax-highlighter@15.5.0/dist/esm/styles/prism";
8
9const CHAT_URL = "/api/chat";
10const STATUS_URL = "/api/status";
11
12const MODELS = [
368
369export default async function server(request: Request): Promise<Response> {
370 // Proxy for DuckDuckGo API calls
371 if (request.method === 'OPTIONS') {
372 return new Response(null, {
379 }
380
381 if (request.url.includes('/api/status')) {
382 try {
383 const statusResponse = await fetch('https://duckduckgo.com/duckchat/v1/status', {
410 }
411
412 if (request.url.includes('/api/chat')) {
413 try {
414 const requestBody = await request.json();
455 <title>DuckDuckGo Chat</title>
456 <meta name="viewport" content="width=device-width, initial-scale=1">
457 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
458 <script src="https://esm.town/v/std/catch"></script>
459 </head>

ddg_chatREADME.md1 match

@kauri•Updated 6 months ago
1Simple AI chat app with markdown reneder utilizing DuckDuckGo Chat API

PSEoutagesmain.tsx1 match

@andreterron•Updated 6 months ago
3// ----- PSE
4
5export const OUTAGES_URL = "https://www.pse.com/api/sitecore/OutageMap/AnonymoussMapListView";
6
7export const PSE_OUTAGES_TABLE_NAME = `pse_outage_checks`;

sqlite_adminREADME.md1 match

@sitrucl•Updated 6 months ago
9To use it on your own Val Town SQLite database, [fork it](https://www.val.town/v/stevekrouse/sqlite_admin/fork) to your account.
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).

twitterAlertREADME.md3 matches

@ekalnow•Updated 6 months ago
4
5This val gets Twitter data via [SocialData](https://socialdata.tools) via
6@stevekrouse/socialDataProxy. Val Town Pro users can call this API
7100 times per day, so be sure not to set this cron to run more than once every 15 min.
8If you want to use it more, get your own [SocialData](https://socialdata.tools)
9API token and pay for it directly.
10
11## 1. Query
13Change the `query` variable for what you want to get notified for.
14
15You can use [Twitter's search operators](https://developer.twitter.com/en/docs/twitter-api/v1/rules-and-filtering/search-operators) to customize your query, for some collection of keywords, filtering out others, and much more!
16
17## 2. Notification

enchantingSilverPelicanmain.tsx1 match

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

new-val-api-demo

@shouser•Updated 17 hours ago
This is an example of using the API to create a val.

groq-api2 file matches

@cameronpak•Updated 21 hours ago
snartapi
mux
Your friendly, neighborhood video API.