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=343&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 6292 results for "api"(614ms)

quarterPriceAuctionScannerscanner.cron.ts1 match

@wolf•Updated 3 weeks ago
3
4const CACHE_BUCKET_PREFIX = "quarterpriceauctionscanner";
5const AUCTIONS_CACHE_KEY = CACHE_BUCKET_PREFIX + "/qpaapi/auctions_data";
6
7export default async function updateAuctionCache() {

quarterPriceAuctionScannerwebsite.http.tsx3 matches

@wolf•Updated 3 weeks ago
40 const fetchCachedData = async () => {
41 try {
42 const response = await fetch("/api/cached-data");
43 const data = await response.json();
44 if (data.success) {
196// Server-side handler
197async function server(request: Request): Promise<Response> {
198 // Handle API requests
199 if (request.url.endsWith("/api/cached-data")) {
200 const { blob } = await import("https://esm.town/v/std/blob?v=13");
201

blogget-old-posts.ts25 matches

@valdottown•Updated 3 weeks ago
19export const oldPosts: BlogPost[] = [
20 {
21 "title": "Solving the internal / external API riddle",
22 "slug": "api-conundrum",
23 "link": "/blog/api-conundrum",
24 "description": "Figuring out how to provide an API that's usable by everyone and fast for us to iterate on",
25 "pubDate": "Thu, 27 Mar 2025 00:00:00 GMT",
26 "author": "Tom MacWright",
27 },
28 {
29 "title": "API Tokens Scopes",
30 "slug": "api-token-scopes",
31 "link": "/blog/api-token-scopes",
32 "description": "Improving security with granular control over permissions",
33 "pubDate": "Fri, 01 Nov 2024 00:00:00 GMT",
59 },
60 {
61 "title": "Expanding the Vals API - RFC",
62 "slug": "expanding-the-vals-api-rfc",
63 "link": "/blog/expanding-the-vals-api-rfc",
64 "description": "Our REST API lets you do a lot - and soon it will enable more",
65 "pubDate": "Fri, 30 Jun 2023 00:00:00 GMT",
66 "author": "André Terron",
133 },
134 {
135 "title": "The perks of a good OpenAPI spec",
136 "slug": "openapi",
137 "link": "/blog/openapi",
138 "description": "Taking advantage of our typed REST API to build a platform around\nVal Town.",
139 "pubDate": "Thu, 25 Jul 2024 00:00:00 GMT",
140 "author": "Tom MacWright",
262 },
263 {
264 "title": "The API we forgot to name",
265 "slug": "the-api-we-forgot-to-name",
266 "link": "/blog/the-api-we-forgot-to-name",
267 "description": "An API that takes a Request and returns a Response - what was that, again?",
268 "pubDate": "Thu, 19 Oct 2023 00:00:00 GMT",
269 "author": "Steve Krouse",
286 },
287 {
288 "title": "Deprecating the Run API",
289 "slug": "deprecating-the-run-api",
290 "link": "/blog/deprecating-the-run-api",
291 "description": "Not every function should be an API",
292 "pubDate": "Wed, 07 Feb 2024 00:00:00 GMT",
293 "author": "André Terron",
321 "slug": "val-town-newsletter-1",
322 "link": "/blog/val-town-newsletter-1",
323 "description": "Programmatic notifications, Hacker News API, and more.",
324 "pubDate": "Wed, 04 Jan 2023 00:00:00 GMT",
325 "author": "Steve Krouse",
450 "slug": "val-town-newsletter-22",
451 "link": "/blog/val-town-newsletter-22",
452 "description": "Townie upgrades, Scoped API permissions, Fal partnership",
453 "pubDate": "Mon, 02 Dec 2024 00:00:00 GMT",
454 "author": "Steve Krouse",

blog-vt2TODOs.md1 match

@jxnblk•Updated 3 weeks ago
3- [ ] Make it faster
4- [ ] Add cache headers for Cloudflare.
5 - [ ] Is there a way to bust the cache manually via api can we call that everytime we save a new version?
6- [ ] Add og: content for new posts hosted here (old posts will have it still)
7- [ ] Deploy it to blog.val.town!

blog-vt2get-old-posts.ts25 matches

@jxnblk•Updated 3 weeks ago
19export const oldPosts: BlogPost[] = [
20 {
21 "title": "Solving the internal / external API riddle",
22 "slug": "api-conundrum",
23 "link": "/blog/api-conundrum",
24 "description": "Figuring out how to provide an API that's usable by everyone and fast for us to iterate on",
25 "pubDate": "Thu, 27 Mar 2025 00:00:00 GMT",
26 "author": "Tom MacWright",
27 },
28 {
29 "title": "API Tokens Scopes",
30 "slug": "api-token-scopes",
31 "link": "/blog/api-token-scopes",
32 "description": "Improving security with granular control over permissions",
33 "pubDate": "Fri, 01 Nov 2024 00:00:00 GMT",
59 },
60 {
61 "title": "Expanding the Vals API - RFC",
62 "slug": "expanding-the-vals-api-rfc",
63 "link": "/blog/expanding-the-vals-api-rfc",
64 "description": "Our REST API lets you do a lot - and soon it will enable more",
65 "pubDate": "Fri, 30 Jun 2023 00:00:00 GMT",
66 "author": "André Terron",
133 },
134 {
135 "title": "The perks of a good OpenAPI spec",
136 "slug": "openapi",
137 "link": "/blog/openapi",
138 "description": "Taking advantage of our typed REST API to build a platform around\nVal Town.",
139 "pubDate": "Thu, 25 Jul 2024 00:00:00 GMT",
140 "author": "Tom MacWright",
262 },
263 {
264 "title": "The API we forgot to name",
265 "slug": "the-api-we-forgot-to-name",
266 "link": "/blog/the-api-we-forgot-to-name",
267 "description": "An API that takes a Request and returns a Response - what was that, again?",
268 "pubDate": "Thu, 19 Oct 2023 00:00:00 GMT",
269 "author": "Steve Krouse",
286 },
287 {
288 "title": "Deprecating the Run API",
289 "slug": "deprecating-the-run-api",
290 "link": "/blog/deprecating-the-run-api",
291 "description": "Not every function should be an API",
292 "pubDate": "Wed, 07 Feb 2024 00:00:00 GMT",
293 "author": "André Terron",
321 "slug": "val-town-newsletter-1",
322 "link": "/blog/val-town-newsletter-1",
323 "description": "Programmatic notifications, Hacker News API, and more.",
324 "pubDate": "Wed, 04 Jan 2023 00:00:00 GMT",
325 "author": "Steve Krouse",
450 "slug": "val-town-newsletter-22",
451 "link": "/blog/val-town-newsletter-22",
452 "description": "Townie upgrades, Scoped API permissions, Fal partnership",
453 "pubDate": "Mon, 02 Dec 2024 00:00:00 GMT",
454 "author": "Steve Krouse",

frankIndigoSwordtailmain.tsx1 match

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

spagindex.html3 matches

@todepond•Updated 4 weeks ago
230 uploadButton.disabled = true;
231 uploadButton.textContent = "Uploading...";
232 const response = await fetch("/api/upload", {
233 method: "POST",
234 body,
251
252 async function fetchUploads() {
253 const response = await fetch("/api/list");
254 const data = await response.json();
255 return data.rows;
395 deleteButton.textContent = "Deleting...";
396 const response = await fetch(
397 `/api/delete`,
398 {
399 method: "POST",

Open-ToownieuseProjectFiles.ts1 match

@toowired•Updated 4 weeks ago
1import { useState, useEffect } from "https://esm.sh/react@18.2.0?dev";
2import { fetchProjectFiles } from "../utils/api.ts";
3
4interface UseProjectFilesProps {

Open-ToownieuseChatLogic.ts4 matches

@toowired•Updated 4 weeks ago
6 project: any;
7 branchId: string | undefined;
8 anthropicApiKey: string;
9 bearerToken: string;
10 selectedFiles: string[];
16 project,
17 branchId,
18 anthropicApiKey,
19 bearerToken,
20 selectedFiles,
35 status,
36 } = useChat({
37 api: "/api/send-message",
38 body: {
39 project,
40 branchId,
41 anthropicApiKey,
42 selectedFiles,
43 images: images

Open-Toowniesystem_prompt.txt7 matches

@toowired•Updated 4 weeks ago
98- For AI-generated images, use: `https://maxm-imggenurl.web.val.run/the-description-of-your-image`
99- **Storage:** DO NOT use the Deno KV module for storage
100- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
101- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
102- **View Source:** Add a view source link with `import.meta.url.replace("esm.town", "val.town")` and include `target="_top"` attribute
103- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
104- **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
105- **Environment Variables:** Use `Deno.env.get('keyname')` and minimize their use - prefer APIs without keys
106- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
107- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
188
189### Backend (Hono) Best Practices
190- Hono is the recommended API framework (similar to Express, Flask, or Sinatra)
191- Main entry point should be `backend/index.ts`
192- **Static asset serving:** Use the utility functions to read and serve project files:
209 });
210 ```
211- Create RESTful API routes for CRUD operations
212- Be careful with error handling as Hono tends to swallow errors
213- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
226- Use React 18.2.0 consistently in all imports and the `@jsxImportSource` pragma
227- Follow the React component pattern from the example project
228- Handle API calls properly with proper error catching
229
230### Database Patterns
257 - For files in the project, use `readFile` helpers
258
2595. **API Design:**
260 - `fetch` handler is the entry point for HTTP vals
261 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

daily-advice-app1 file match

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

runValAPIEx2 file matches

@charmaine•Updated 1 day ago
rapilot330
YoungPapi