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=41&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 18274 results for "api"(4691ms)

Townie-09index.ts7 matches

@jxnblk•Updated 2 days ago
1import { basicAuthMiddleware } from "./auth.ts";
2import { handleApiRequest } from "./api/index.ts";
3import { getRequests } from "./api/requests.ts";
4import { getUserSummary } from "./api/user-summary.ts";
5import { getInferenceCalls } from "./api/inference-calls.ts";
6import { renderDashboard } from "./views/dashboard.ts";
7import { renderRequests } from "./views/requests.ts";
22 const path = url.pathname;
23
24 // Handle API requests
25 if (path.startsWith("/api/")) {
26 return handleApiRequest(req);
27 }
28

Townie-09index.ts5 matches

@jxnblk•Updated 2 days ago
4
5/**
6 * Handle API requests
7 */
8export async function handleApiRequest(req: Request): Promise<Response> {
9 const url = new URL(req.url);
10 const path = url.pathname.replace("/api/", "");
11
12 try {
13 // Route to the appropriate API handler
14 if (path === "requests") {
15 const usageId = url.searchParams.get("usage_id");
59 }
60 } catch (error) {
61 console.error("API error:", error);
62 return new Response(JSON.stringify({ error: error.message }), {
63 status: 500,

Townie-09Home.tsx5 matches

@jxnblk•Updated 2 days ago
32 <ol>
33 <li>
34 Login with your Val Town API token (with projects:read, projects:write, user:read permissions)
35 </li>
36 <li>Select a project to work on</li>
70 </div>
71 <h3>Cost Tracking</h3>
72 <p>See estimated API usage costs for each interaction</p>
73 </div>
74 </section>
79 <ul>
80 <li>React frontend with TypeScript</li>
81 <li>Hono API server backend</li>
82 <li>Web Audio API for sound notifications</li>
83 <li>AI SDK for Claude integration</li>
84 </ul>
85 <p>
86 The application proxies requests to the Anthropic API and Val Town API, allowing Claude to view and edit your
87 project files directly.
88 </p>

Townie-09.cursorrules10 matches

@jxnblk•Updated 2 days ago
13- Generate code in TypeScript or TSX
14- Add appropriate TypeScript types and interfaces for all data structures
15- Prefer official SDKs or libraries than writing API calls directly
16- Ask the user to supply API or library documentation if you are at all unsure about it
17- **Never bake in secrets into the code** - always use environment variables
18- Include comments explaining complex logic (avoid commenting obvious operations)
23### 1. HTTP Trigger
24
25- Create web APIs and endpoints
26- Handle HTTP requests and responses
27- Example structure:
173However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
174If you need access to this data on the client, run it in the server and pass it to the client by splicing it into the HTML page
175or by making an API request for it.
176
177## Val Town Platform Specifics
181- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
182- **Storage:** DO NOT use the Deno KV module for storage
183- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
184- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
185- **View Source:** Add a view source link by importing & using `import.meta.url.replace("ems.sh", "val.town)"` (or passing this data to the client) and include `target="_top"` attribute
186- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
187- **Error Handling:** Only use try...catch when there's a clear local resolution; Avoid catches that merely log or return 500s. Let errors bubble up with full context
188- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
189- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
190- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
224### Backend (Hono) Best Practices
225
226- Hono is the recommended API framework
227- Main entry point should be `backend/index.ts`
228- **Static asset serving:** Use the utility functions to read and serve project files:
248 });
249 ```
250- Create RESTful API routes for CRUD operations
251- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
252 ```ts
285 - For files in the project, use `readFile` helpers
286
2875. **API Design:**
288 - `fetch` handler is the entry point for HTTP vals
289 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

Discord-to-LinearREADME.md2 matches

@hussufo•Updated 2 days ago
17- `DISCORD_MONITORED_CHANNELS`: Comma-separated channel IDs to monitor (right-click channel → Copy ID)
18 - Example: `1327384540187983926,1327384540187983927`
19- `LINEAR_API_KEY`: Your Linear API key
20 - Go to Linear Settings → API → Personal API keys → Create key
21- `LINEAR_TEAM_ID`: Your Linear team UUID, this is NOT the 3 letter `Team Identifier` found in issue IDs
22 - On any Linear page, type `CMD+K` to pull up the quick menu + enter `Dev: Copy model UUID` to copy your UUID

Discord-to-Linearmain.tsx3 matches

@hussufo•Updated 2 days ago
1import { blob } from "https://esm.town/v/std/blob";
2import { CONFIG } from "./backend/config.tsx";
3import { DiscordAPI } from "./backend/discord.tsx";
4import { LinearSDK } from "./backend/linear.tsx";
5
24
25 // Initialize services
26 const discord = new DiscordAPI();
27 const linear = new LinearSDK();
28
45 */
46async function processChannelReactions(
47 discord: DiscordAPI,
48 linear: LinearSDK,
49 serverId: string,

Discord-to-Linearlinear.tsx1 match

@hussufo•Updated 2 days ago
6
7 constructor() {
8 this.client = new LinearClient({ apiKey: Deno.env.get("LINEAR_API_KEY")! });
9 }
10

PlaywrightDemomain.ts3 matches

@hussufo•Updated 2 days ago
3import { Browser } from "npm:playwright-core";
4import { valTownChromium } from "./valTownChromium.ts";
5import { STEEL_API_KEY } from "./consts.ts";
6import { hackerNewsDemo } from "./hackerNewsDemo.ts";
7
8const client = new Steel({
9 steelAPIKey: STEEL_API_KEY,
10});
11
19
20 browser = await valTownChromium.connectOverCDP(
21 `wss://connect.steel.dev?apiKey=${STEEL_API_KEY}&sessionId=${session.id}`,
22 { slowMo: 0 },
23 );

PlaywrightDemoconsts.ts1 match

@hussufo•Updated 2 days ago
1export const STEEL_API_KEY = Deno.env.get("STEEL_API_KEY");
2

weatherWeatherMap.tsx13 matches

@dukky•Updated 2 days ago
17export default function WeatherMap({ onLocationSelect, selectedLocation }: WeatherMapProps) {
18 const mapRef = useRef<HTMLDivElement>(null);
19 const mapInstanceRef = useRef<any>(null);
20 const markersRef = useRef<any[]>([]);
21 const selectedMarkerRef = useRef<any>(null);
29 // Create map centered on UK
30 const map = window.L.map(mapRef.current).setView([54.5, -2], 3);
31 mapInstanceRef.current = map;
32
33 // Add OpenStreetMap tiles
46
47 return () => {
48 if (mapInstanceRef.current) {
49 mapInstanceRef.current.remove();
50 mapInstanceRef.current = null;
51 }
52 if (selectedMarkerRef.current) {
58 // Zoom to selected location when it changes
59 useEffect(() => {
60 if (!mapInstanceRef.current || !selectedLocation) return;
61
62 const { latitude, longitude } = selectedLocation;
64 // Remove previous selected location marker
65 if (selectedMarkerRef.current) {
66 mapInstanceRef.current.removeLayer(selectedMarkerRef.current);
67 selectedMarkerRef.current = null;
68 }
69
70 // Zoom to the selected location with a nice animation
71 mapInstanceRef.current.setView([latitude, longitude], 12, {
72 animate: true,
73 duration: 1.0
102 icon: selectedIcon,
103 zIndexOffset: 1000 // Ensure it appears above other markers
104 }).addTo(mapInstanceRef.current);
105
106 }, [selectedLocation]);
108 // Update markers when weather data changes
109 useEffect(() => {
110 if (!mapInstanceRef.current || !window.L) return;
111
112 // Clear existing markers
113 markersRef.current.forEach(marker => {
114 mapInstanceRef.current.removeLayer(marker);
115 });
116 markersRef.current = [];
147 const marker = window.L.marker([point.latitude, point.longitude], {
148 icon: customIcon
149 }).addTo(mapInstanceRef.current);
150
151 // Add popup with detailed info
192 try {
193 setLoading(true);
194 const response = await fetch('/api/weather/map');
195 if (response.ok) {
196 const data = await response.json();

github-api1 file match

@cricks_unmixed4u•Updated 9 hours ago

beeminder-api4 file matches

@cricks_unmixed4u•Updated 10 hours ago
Kapil01
apiv1