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=49&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 4984 results for "api"(422ms)

vt-bloglive-reload.ts1 match

@charmaine•Updated 1 week ago
82 // if we wanted to create a /lastUpdatedAt route,
83 // which would let us pass a val town bearer token, we could do that here
84 // gives us 10k API requests per minute instead of 1k
85 // and would work with private projects
86

vt-blogget-old-posts.ts25 matches

@charmaine•Updated 1 week 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",

vt-blog2025-04-08-migration.md1 match

@charmaine•Updated 1 week ago
83We didn't. We left them where they are, and proxy to them.
84
85Writing a proxy in Val Town (or any functions platform with the ['fetch handler' interface](https://blog.val.town/blog/the-api-we-forgot-to-name/)) is a delight:
86
87```ts

MyStevensREADME.md5 matches

@billogiovanni•Updated 1 week ago
8## Hono
9
10This app uses [Hono](https://hono.dev/) as the API framework. You can think of Hono as a replacement for [ExpressJS](https://expressjs.com/) that works in serverless environments like Val Town or Cloudflare Workers. If you come from Python or Ruby, Hono is also a lot like [Flask](https://github.com/pallets/flask) or [Sinatra](https://github.com/sinatra/sinatra), respectively.
11
12## Serving assets to the frontend
20### `index.html`
21
22The most complicated part of this backend API is serving index.html. In this app (like most apps) we serve it at the root, ie `GET /`.
23
24We *bootstrap* `index.html` with some initial data from the server, so that it gets dynamically injected JSON data without having to make another round-trip request to the server to get that data on the frontend. This is a common pattern for client-side rendered apps.
25
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors
31
32Hono and other API frameworks have a habit of swallowing up Errors. We turn off this default behavior by re-throwing errors, because we think most of the time you'll want to see the full stack trace instead of merely "Internal Server Error". You can customize how you want errors to appear.

MyStevensNotebookView.tsx5 matches

@billogiovanni•Updated 1 week ago
8import { type Memory } from "../../shared/types.ts";
9
10const API_BASE = "/api/memories";
11const MEMORIES_PER_PAGE = 20;
12
71 setError(null);
72 try {
73 const response = await fetch(API_BASE);
74 if (!response.ok) {
75 throw new Error(`HTTP error! status: ${response.status}`);
100
101 try {
102 const response = await fetch(API_BASE, {
103 method: "POST",
104 headers: { "Content-Type": "application/json" },
123
124 try {
125 const response = await fetch(`${API_BASE}/${id}`, {
126 method: "DELETE",
127 });
155
156 try {
157 const response = await fetch(`${API_BASE}/${editingMemory.id}`, {
158 method: "PUT",
159 headers: { "Content-Type": "application/json" },

MyStevensindex.ts11 matches

@billogiovanni•Updated 1 week ago
18});
19
20// --- API Routes for Memories ---
21
22// GET /api/memories - Retrieve all memories
23app.get("/api/memories", async (c) => {
24 const memories = await getAllMemories();
25 return c.json(memories);
26});
27
28// POST /api/memories - Create a new memory
29app.post("/api/memories", async (c) => {
30 const body = await c.req.json<Omit<Memory, "id">>();
31 if (!body.text) {
36});
37
38// PUT /api/memories/:id - Update an existing memory
39app.put("/api/memories/:id", async (c) => {
40 const id = c.req.param("id");
41 const body = await c.req.json<Partial<Omit<Memory, "id">>>();
58});
59
60// DELETE /api/memories/:id - Delete a memory
61app.delete("/api/memories/:id", async (c) => {
62 const id = c.req.param("id");
63 try {
75// --- Blob Image Serving Routes ---
76
77// GET /api/images/:filename - Serve images from blob storage
78app.get("/api/images/:filename", async (c) => {
79 const filename = c.req.param("filename");
80

MyStevensindex.html2 matches

@billogiovanni•Updated 1 week ago
12 type="image/svg+xml"
13 />
14 <link rel="preconnect" href="https://fonts.googleapis.com" />
15 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
16 <link
17 href="https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400..700&display=swap"
18 rel="stylesheet"
19 />

MyStevenshandleUSPSEmail.ts5 matches

@billogiovanni•Updated 1 week ago
85 console.log(e.text);
86
87 // Get Anthropic API key from environment
88 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
89 if (!apiKey) {
90 console.error("Anthropic API key is not configured for this val.");
91 return;
92 }
93
94 // Initialize Anthropic client
95 const anthropic = new Anthropic({ apiKey });
96
97 // Process each image attachment serially

MyStevenshandleTelegramMessage.ts7 matches

@billogiovanni•Updated 1 week ago
92
93/**
94 * Format chat history for Anthropic API
95 */
96function formatChatHistoryForAI(history) {
321bot.on("message", async (ctx) => {
322 try {
323 // Get Anthropic API key from environment
324 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
325 if (!apiKey) {
326 console.error("Anthropic API key is not configured.");
327 ctx.reply(
328 "I apologize, but I'm not properly configured at the moment. Please inform the household administrator."
332
333 // Initialize Anthropic client
334 const anthropic = new Anthropic({ apiKey });
335
336 // Get message text and user info
502 // Set webhook if it is not set yet
503 if (!isEndpointSet) {
504 await bot.api.setWebhook(req.url, {
505 secret_token: SECRET_TOKEN,
506 });

MyStevensgetWeather.ts5 matches

@billogiovanni•Updated 1 week ago
27async function generateConciseWeatherSummary(weatherDay) {
28 try {
29 // Get API key from environment
30 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
31 if (!apiKey) {
32 console.error("Anthropic API key is not configured.");
33 return null;
34 }
35
36 // Initialize Anthropic client
37 const anthropic = new Anthropic({ apiKey });
38
39 const response = await anthropic.messages.create({

PassphraseAPI2 file matches

@wolf•Updated 2 days ago

openapi2 file matches

@stevekrouse•Updated 4 days ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)