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=536&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 25434 results for "api"(4177ms)

doodleadmin.http.ts6 matches

@arfan•Updated 2 months ago
85
86 <script>
87 const API_BASE = 'https://doodle-api.val.run';
88 const eventId = '${eventId || ''}';
89 const secret = '${secret || ''}';
103 async function loadEvent() {
104 try {
105 const response = await fetch(\`\${API_BASE}/events/\${eventId}\`);
106 const data = await response.json();
107
168 if (eventId && secret) {
169 // Update existing event
170 response = await fetch(\`\${API_BASE}/events/\${eventId}\`, {
171 method: 'PATCH',
172 headers: { 'Content-Type': 'application/json' },
175 } else {
176 // Create new event
177 response = await fetch(\`\${API_BASE}/events\`, {
178 method: 'POST',
179 headers: { 'Content-Type': 'application/json' },
227 const fullEditUrl = editUrl.startsWith('http') ? editUrl : window.location.origin + editUrl;
228 const fullAnswerUrl = answerUrl.startsWith('http') ? answerUrl : window.location.origin + answerUrl;
229 const response = await fetch(\`\${API_BASE}/email\`, {
230 method: 'POST',
231 headers: { 'Content-Type': 'application/json' },
259
260 try {
261 await fetch(\`\${API_BASE}/email\`, {
262 method: 'POST',
263 headers: { 'Content-Type': 'application/json' },

ChatIMPLEMENTATION-SUMMARY-AFFORDANCES.md2 matches

@c15r•Updated 2 months ago
225
226### Fixed Issues
227- **JSON Schema Validation**: Fixed invalid schema types for Anthropic API
228- **Circular Dependencies**: Implemented lazy loading to prevent import issues
229- **App Loading**: Resolved module loading problems that caused blank page
231### Architecture Decisions
232- **File-based Components**: Components loaded from project files for version control
233- **Standardized Interface**: Consistent API across all component types
234- **Container Abstraction**: Separate managers for each container type
235- **Safe Method Calls**: Proxy system for secure method invocation

oauth-connectmain.tsx4 matches

@stevekrouse•Updated 2 months ago
39});
40
41app.get("/api/tokens", async (c) => {
42 const user = c.get("user");
43 return c.json(await getTokensByUserId(user.id));
47 Deno.env.get("SLACK_CLIENT_ID"),
48 Deno.env.get("SLACK_CLIENT_SECRET"),
49 "https://oauth-connect.val.run/api/callback/slack",
50);
51app.get("/api/start-connection/:service", (c) => {
52 const state = arctic.generateState();
53
71});
72
73app.get("/api/callback/:service", async (c) => {
74 const service = c.req.param("service");
75

ChatAFFORDANCE-FRAMEWORK.md2 matches

@c15r•Updated 2 months ago
1# UI Affordance Registration Framework
2
3A flexible system for dynamically registering and controlling UI components through client-side tools. This framework allows the assistant to create rich, interactive UI experiences by registering components in dedicated containers and interacting with them through a standardized API.
4
5## Overview
8- **Dynamic Component Registration**: Load and mount components from file keys
9- **Multiple Container Types**: Overlay, header, footer, sidebar, and inline containers
10- **Standardized Interface**: Consistent API for component interaction
11- **Lifecycle Management**: Proper mounting, unmounting, and cleanup
12- **Method Invocation**: Safe method calls on registered components

gpt-wrapperindex.ts8 matches

@cricks_unmixed4u•Updated 2 months ago
13});
14
15// GreenPT API wrapper endpoint
16app.post("/v1/chat/completions", async (c) => {
17 try {
18 const apiKey = Deno.env.get("GREENPT_API_KEY");
19 if (!apiKey) {
20 return c.json({ error: "GREENPT_API_KEY not configured" }, 500);
21 }
22
38 };
39
40 const response = await fetch("https://api.greenpt.ai/v1/chat/completions", {
41 method: "POST",
42 headers: {
43 "Content-Type": "application/json",
44 "Authorization": `Bearer ${apiKey}`,
45 },
46 body: JSON.stringify(
59 const errorText = await response.text();
60 return c.json({
61 error: `GreenPT API error: ${response.status} ${errorText}`,
62 }, response.status);
63 }
72// Health check endpoint
73app.get("/health", (c) => {
74 return c.json({ status: "ok", service: "GreenPT API Wrapper" });
75});
76

gpt-wrapperknowledge.md13 matches

@cricks_unmixed4u•Updated 2 months ago
14- Generate code in TypeScript or TSX
15- Add appropriate TypeScript types and interfaces for all data structures
16- Prefer official SDKs or libraries than writing API calls directly
17- Ask the user to supply API or library documentation if you are at all unsure about it
18- **Never bake in secrets into the code** - always use environment variables
19- Include comments explaining complex logic (avoid commenting obvious operations)
24### 1. HTTP Trigger
25
26- Create web APIs and endpoints
27- Handle HTTP requests and responses
28- Example structure:
146Use GlobalRateLimitedChatOpenAI(model, requestsPerSecond) to enforce a global rate limit on chat completions, suitable for shared or public-facing endpoints.
147Val Town/Platform Notes
148Uses Val Town’s standard SQLite API for persistent storage.
149Designed for server-side use (no browser-specific code).
150No secrets are hardcoded; OpenAI API keys are managed by the OpenAI SDK/environment.
151
152### Email
215However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
216If 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
217or by making an API request for it.
218
219## Val Town Platform Specifics
223- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
224- **Storage:** DO NOT use the Deno KV module for storage
225- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
226- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
227- **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
228- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
229- **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
230- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
231- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
232- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
266### Backend (Hono) Best Practices
267
268- Hono is the recommended API framework
269- Main entry point should be `backend/index.ts`
270- **Static asset serving:** Use the utility functions to read and serve project files:
290 });
291 ```
292- Create RESTful API routes for CRUD operations
293- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
294 ```ts
327 - For files in the project, use `readFile` helpers
328
3295. **API Design:**
330 - `fetch` handler is the entry point for HTTP vals
331 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`
351```
352
353`your-api-key` can be read from environment variables GREENPT_API_KEY.
354
355The expected response to the curl call would be

gpt-wrapperopenai-client.mdc2 matches

@cricks_unmixed4u•Updated 2 months ago
15Use GlobalRateLimitedChatOpenAI(model, requestsPerSecond) to enforce a global rate limit on chat completions, suitable for shared or public-facing endpoints.
16Val Town/Platform Notes
17Uses Val Town’s standard SQLite API for persistent storage.
18Designed for server-side use (no browser-specific code).
19No secrets are hardcoded; OpenAI API keys are managed by the OpenAI SDK/environment.

gpt-wrapper.cursorrules10 matches

@cricks_unmixed4u•Updated 2 months 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`

reactHonoStarter-michelleindex.ts2 matches

@stevekrouse•Updated 2 months ago
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error

oauth-connectHomePage.tsx2 matches

@stevekrouse•Updated 2 months ago
4
5export default function({ onLogin }) {
6 const [apiKey, setApiKey] = useState("");
7 const [isLoading, setIsLoading] = useState(false);
8 const [error, onError] = useState("");
11 <div className="max-w-lg mx-auto mt-12 p-6 flex flex-col gap-6">
12 <h1 className="text-3xl">Val Town Oauth Connect</h1>
13 <a href="/api/start-connection/slack" className="text-blue-500 hover:underline">Connect to Slack</a>
14 </div>
15 );

PixelPixelApiMonitor1 file match

@selfire1•Updated 11 hours ago
Regularly polls the API and messages on an error.

weatherApp1 file match

@dcm31•Updated 17 hours ago
A simple weather app with dropdown cities using Open-Meteo API
fapian
<("<) <(")> (>")>
Kapil01