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%22Optional%20title%22?q=api&page=188&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 15454 results for "api"(2332ms)

TownieHome.tsx6 matches

@japhethkingjackson•Updated 1 week ago
38 <ol>
39 <li>
40 Login with your Val Town API token (with projects:read,
41 projects:write, user:read permissions)
42 </li>
77 </div>
78 <h3>Cost Tracking</h3>
79 <p>See estimated API usage costs for each interaction</p>
80 </div>
81 </section>
86 <ul>
87 <li>React frontend with TypeScript</li>
88 <li>Hono API server backend</li>
89 <li>Web Audio API for sound notifications</li>
90 <li>AI SDK for Claude integration</li>
91 </ul>
92 <p>
93 The application proxies requests to the Anthropic API and Val Town
94 API, allowing Claude to view and edit your project files directly.
95 </p>
96 <div>

Townie.cursorrules10 matches

@japhethkingjackson•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`

cartaportecarta-porte.tsx5 matches

@arequipe•Updated 1 week ago
1export default async function handler(req: Request): Promise<Response> {
2 const AIRTABLE_API_KEY = Deno.env.get("AIRTABLE_API_KEY")!;
3 const AIRTABLE_BASE_ID = Deno.env.get("AIRTABLE_BASE_ID")!;
4 const FACTURAMA_AUTH = Deno.env.get("FACTURAMA_AUTH")!;
12
13 const airtableHeaders = {
14 Authorization: `Bearer ${AIRTABLE_API_KEY}`,
15 "Content-Type": "application/json",
16 };
18 const fetchAirtableRecord = async () => {
19 const res = await fetch(
20 `https://api.airtable.com/v0/${AIRTABLE_BASE_ID}/${VIAJES_TABLE}/${recordId}`,
21 { headers: airtableHeaders },
22 );
27 const updateAirtable = async (uuid: string, facturamaId: string) => {
28 await fetch(
29 `https://api.airtable.com/v0/${AIRTABLE_BASE_ID}/${VIAJES_TABLE}/${recordId}`,
30 {
31 method: "PATCH",
191 };
192
193 const facturamaRes = await fetch("https://apisandbox.facturama.mx/3/cfdis", {
194 method: "POST",
195 headers: {

mahiindex.ts4 matches

@Mahi7•Updated 1 week ago
17}
18
19type ApiResponse = SuccessResponse | ErrorResponse;
20
21/**
67 }
68
69 // Call OpenAI Vision API to analyze the image
70 const response = await openai.chat.completions.create({
71 model: "gpt-4o",
93 console.error("Error analyzing image:", error);
94
95 // Determine if it's an OpenAI API error
96 const errorMessage = error instanceof Error
97 ? error.message
115 * Helper function to create JSON responses
116 */
117function jsonResponse(data: ApiResponse, status = 200): Response {
118 return new Response(JSON.stringify(data), {
119 status,

mahiindex.html1 match

@Mahi7•Updated 1 week ago
125 }
126
127 // Analyze the image using the API
128 async function analyzeImage() {
129 const imageUrl = imageUrlInput.value.trim();

mahiREADME.md3 matches

@Mahi7•Updated 1 week ago
1# AI Image Recognition App
2
3This Val Town app uses OpenAI's Vision API to analyze images and provide descriptions of their content.
4
5## Features
11## Project Structure
12
13- `/index.ts` - Main HTTP endpoint that handles API requests
14- `/frontend/index.html` - User interface for the app
15
23## Technologies Used
24
25- OpenAI Vision API
26- TailwindCSS for styling
27- Val Town's blob storage for caching (optional future enhancement)

TownieuseUser.tsx1 match

@pachchigaryash•Updated 1 week ago
1import { useState, useEffect } from "react";
2
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {

Townieuser-summary.ts1 match

@pachchigaryash•Updated 1 week ago
20 SUM(num_images) as total_images
21 FROM ${USAGE_TABLE}
22 WHERE our_api_token = 1
23 GROUP BY user_id, username
24 ORDER BY total_price DESC

TownieuseProject.tsx2 matches

@pachchigaryash•Updated 1 week ago
1import { useState, useEffect } from "react";
2
3const PROJECT_ENDPOINT = "/api/project";
4const FILES_ENDPOINT = "/api/project-files";
5
6export function useProject(projectId: string, branchId?: string) {

TownieuseProjects.tsx1 match

@pachchigaryash•Updated 1 week ago
1import { useState, useEffect } from "react";
2
3const ENDPOINT = "/api/projects-loader";
4
5export function useProjects() {

HN-fetch-call2 file matches

@ImGqb•Updated 2 days ago
fetch HackerNews by API

token-server1 file match

@kwhinnery_openai•Updated 3 days ago
Mint tokens to use with the OpenAI Realtime API for WebRTC
Kapil01
apiv1