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=299&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 11890 results for "api"(784ms)

logoWorkshopOpenMojiLogoPreview.tsx4 matches

@dcm31•Updated 3 weeks ago
6const DEFAULT_TEXT_X_POSITION = 112;
7
8// Default vertical spacing factor from the logoAPI implementation
9const DEFAULT_VERTICAL_SPACING_FACTOR = 0.2;
10
63 maxHeight,
64 fontFamily,
65 null, // No SVG ref - use the same algorithm as API
66 textXPosition,
67 emojiX - textXPosition - 20, // Available width
126 fontStyle={isItalicTop ? "italic" : "normal"}
127 textAnchor="middle" // Always center text
128 dominantBaseline="central" // Match logoAPI exactly
129 fill={textColor}
130 >
142 fontStyle={isItalicBottom ? "italic" : "normal"}
143 textAnchor="middle" // Always center text
144 dominantBaseline="central" // Match logoAPI exactly
145 fill={primaryColor}
146 >

logoWorkshopOpenMojizLogoGenerator.tsx2 matches

@dcm31•Updated 3 weeks ago
56
57/**
58 * Create an API endpoint URL to generate a logo with the given parameters
59 */
60export function createLogoAPIUrl(baseUrl, firstPart, lastPart, fontFamily, textColor, primaryColor, secondaryColor, bgColor) {
61 const url = new URL('/generate', baseUrl);
62

logoWorkshopOpenMojiTextEditor.tsx1 match

@dcm31•Updated 3 weeks ago
2import React from "https://esm.sh/react@18.2.0";
3
4// Default vertical spacing factor from the logoAPI implementation
5const DEFAULT_VERTICAL_SPACING_FACTOR = 0.2;
6

stevensDemoREADME.md1 match

@Waryaa•Updated 3 weeks ago
53You'll need to set up some environment variables to make it run.
54
55- `ANTHROPIC_API_KEY` for LLM calls
56- You'll need to follow [these instructions](https://docs.val.town/integrations/telegram/) to make a telegram bot, and set `TELEGRAM_TOKEN`. You'll also need to get a `TELEGRAM_CHAT_ID` in order to have the bot remember chat contents.
57- For the Google Calendar integration you'll need `GOOGLE_CALENDAR_ACCOUNT_ID` and `GOOGLE_CALENDAR_CALENDAR_ID`. See [these instuctions](https://www.val.town/v/stevekrouse/pipedream) for details.

stevensDemoREADME.md5 matches

@Waryaa•Updated 3 weeks 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.

stevensDemoNotebookView.tsx5 matches

@Waryaa•Updated 3 weeks 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" },

stevensDemoindex.ts11 matches

@Waryaa•Updated 3 weeks ago
26});
27
28// --- API Routes for Memories ---
29
30// GET /api/memories - Retrieve all memories
31app.get("/api/memories", async (c) => {
32 const memories = await getAllMemories();
33 return c.json(memories);
34});
35
36// POST /api/memories - Create a new memory
37app.post("/api/memories", async (c) => {
38 const body = await c.req.json<Omit<Memory, "id">>();
39 if (!body.text) {
44});
45
46// PUT /api/memories/:id - Update an existing memory
47app.put("/api/memories/:id", async (c) => {
48 const id = c.req.param("id");
49 const body = await c.req.json<Partial<Omit<Memory, "id">>>();
66});
67
68// DELETE /api/memories/:id - Delete a memory
69app.delete("/api/memories/:id", async (c) => {
70 const id = c.req.param("id");
71 try {
83// --- Blob Image Serving Routes ---
84
85// GET /api/images/:filename - Serve images from blob storage
86app.get("/api/images/:filename", async (c) => {
87 const filename = c.req.param("filename");
88

stevensDemoindex.html2 matches

@Waryaa•Updated 3 weeks 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 />

stevensDemohandleUSPSEmail.ts5 matches

@Waryaa•Updated 3 weeks 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

stevensDemogetWeather.ts5 matches

@Waryaa•Updated 3 weeks 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({

social_data_api_project3 file matches

@tsuchi_ya•Updated 21 hours ago

simple-scrabble-api1 file match

@bry•Updated 1 day ago
apiv1
papimark21