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/image-url.jpg%20%22Image%20title%22?q=api&page=89&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 25397 results for "api"(7508ms)

untitled-61main.tsx1 match

@alikeey•Updated 1 week ago
8• Display each summary in a card layout: headline, short summary, timestamp, and source link.
9• Functionality
10• Fetch Somali news articles from APIs (local news websites or RSS feeds).
11• Use Gemini AI to summarize the article into 3–5 bullet points.
12• Provide an option to switch between Somali and English summaries.

untitled-7046main.tsx1 match

@alikeey•Updated 1 week ago
8• Display each summary in a card layout: headline, short summary, timestamp, and source link.
9• Functionality
10• Fetch Somali news articles from APIs (local news websites or RSS feeds).
11• Use Gemini AI to summarize the article into 3–5 bullet points.
12• Provide an option to switch between Somali and English summaries.

value-sortknowledge.md14 matches

@cricks_unmixed4u•Updated 1 week 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:
135## GreenPTClient
136
137The `GreenPTClient` is a function that allows interaction with the GreenPT API for chat completions. It accepts a model parameter and provides an `invoke` method to send messages and retrieve responses asynchronously. To ensure API security, it requires an API key stored in environment variables.
138
139### Example Usage
146async function getChatResponse() {
147 const messages = [
148 { role: "user", content: "What is the capital of France?" },
149 ];
150
153 console.log("AI Response:", response);
154 } catch (error) {
155 console.error("Error invoking GreenPT API:", error);
156 }
157}
161```
162
163In this example, we create an instance of `GreenPTClient`, send a message asking about the capital of France, and log the AI's response. Error handling is included to catch any issues with the API call.
164
165### Email
228However, it's *extremely importing* to note that `parseProject` and other Standard Library utilities ONLY RUN ON THE SERVER.
229If 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
230or by making an API request for it.
231
232## Val Town Platform Specifics
236- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
237- **Storage:** DO NOT use the Deno KV module for storage
238- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
239- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
240- **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
241- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
242- **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
243- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
244- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
245- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
279### Backend (Hono) Best Practices
280
281- Hono is the recommended API framework
282- Main entry point should be `backend/index.ts`
283- **Static asset serving:** Use the utility functions to read and serve project files:
303 });
304 ```
305- Create RESTful API routes for CRUD operations
306- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
307 ```ts
340 - For files in the project, use `readFile` helpers
341
3425. **API Design:**
343 - `fetch` handler is the entry point for HTTP vals
344 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

value-sortopenai-client.mdc2 matches

@cricks_unmixed4u•Updated 1 week 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.

value-sort.cursorrules10 matches

@cricks_unmixed4u•Updated 1 week 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`

untitled-3540main.tsx1 match

@dmisdm•Updated 1 week ago
12 };
13
14 return fetch("https://extraction-api.nanonets.com/extract", {
15 method: "POST",
16 headers: headers,

tennis_scoreboard_espn_3main.tsx3 matches

@maxp•Updated 1 week ago
5// ===============================
6
7// [REPO-SWAP #1]: replace this stub with: import { logger } from "@api/shared/logger"
8// and then: const log = logger.child({ label: "tool:topic:tennis-liveboard" })
9const log = {
179}
180
181// ---------- ESPN API ----------
182async function fetchBucket(tour: "atp" | "wta", day: string) {
183 const url =
184 `https://site.api.espn.com/apis/site/v2/sports/tennis/${tour}/scoreboard?dates=${day}&_=${Date.now()}`;
185 const res = await fetch(url, { headers: { "Cache-Control": "no-cache" } });
186 if (!res.ok) return null;

hello-realtimeutils.ts8 matches

@dawilco•Updated 1 week ago
1const MODEL = "gpt-realtime";
2const INSTRUCTIONS = `
3 Greet the user in English, and thank them for trying the new OpenAI Realtime API.
4 Give them a brief summary based on the list below, and then ask if they have any questions.
5 Answer questions using the information below. For questions outside this scope,
7 ---
8 Short summary:
9 - The Realtime API is now generally available, and has improved instruction following, voice naturalness, and audio quality.
10 There are two new voices and it's easier to develop for. There's also a new telephony integration for phone scenarios.
11 Full list of improvements:
16 - higher audio quality
17 - improved handling of alphanumerics (eg, properly understanding credit card and phone numbers)
18 - support for the OpenAI Prompts API
19 - support for MCP-based tools
20 - auto-truncation to reduce context size
21 - native telephony support, making it simple to connect voice calls to existing Realtime API applications
22 - when using WebRTC, you can connect without needing an ephemeral token
23 - when using WebRTC, you can now control sessions (including tool calls) from the server
27const VOICE = "marin";
28
29const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
30if (!OPENAI_API_KEY) {
31 throw new Error("🔴 OpenAI API key not configured");
32}
33
34export function makeHeaders(contentType?: string) {
35 const obj: Record<string, string> = {
36 Authorization: `Bearer ${OPENAI_API_KEY}`,
37 };
38 if (contentType) obj["Content-Type"] = contentType;

hello-realtimesip.ts1 match

@dawilco•Updated 1 week ago
27
28 // Accept the call.
29 const url = `https://api.openai.com/v1/realtime/calls/${callId}/accept`;
30 const headers = makeHeaders("application/json");
31 const body = JSON.stringify(makeSession());

hello-realtimertc.ts1 match

@dawilco•Updated 1 week ago
7rtc.post("/", async (c) => {
8 // Create the call.
9 const url = "https://api.openai.com/v1/realtime/calls";
10 const headers = makeHeaders();
11 const fd = new FormData();

PixelPixelApiMonitor1 file match

@selfire1•Updated 16 mins ago
Regularly polls the API and messages on an error.

weatherApp1 file match

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