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=178&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 14864 results for "api"(1706ms)

Townie-06index.ts7 matches

@jxnblk•Updated 1 week ago
1import { basicAuthMiddleware } from "./auth.ts";
2import { handleApiRequest } from "./api/index.ts";
3import { getRequests } from "./api/requests.ts";
4import { getUserSummary } from "./api/user-summary.ts";
5import { getInferenceCalls } from "./api/inference-calls.ts";
6import { renderDashboard } from "./views/dashboard.ts";
7import { renderRequests } from "./views/requests.ts";
22 const path = url.pathname;
23
24 // Handle API requests
25 if (path.startsWith("/api/")) {
26 return handleApiRequest(req);
27 }
28

Townie-06index.ts5 matches

@jxnblk•Updated 1 week ago
4
5/**
6 * Handle API requests
7 */
8export async function handleApiRequest(req: Request): Promise<Response> {
9 const url = new URL(req.url);
10 const path = url.pathname.replace("/api/", "");
11
12 try {
13 // Route to the appropriate API handler
14 if (path === "requests") {
15 const usageId = url.searchParams.get("usage_id");
59 }
60 } catch (error) {
61 console.error("API error:", error);
62 return new Response(JSON.stringify({ error: error.message }), {
63 status: 500,

Townie-06Home.tsx6 matches

@jxnblk•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-06.cursorrules10 matches

@jxnblk•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-3074README.md1 match

@adewoleef123•Updated 1 week ago
5## Structure
6
7- `types.ts` - TypeScript interfaces for data models and API responses
8
9## Usage

untitled-3074README.md7 matches

@adewoleef123•Updated 1 week ago
5## Structure
6
7- `index.ts` - Main entry point for the HTTP API
8- `database/` - Database schema and queries
9 - `migrations.ts` - Database table definitions
10 - `queries.ts` - Functions for interacting with the database
11
12## API Endpoints
13
14### Jobs
15
16- `GET /api/jobs` - Get all job postings
17- `POST /api/jobs` - Create a new job posting
18
19### Chat
20
21- `GET /api/chat` - Get chat messages
22- `POST /api/chat` - Create a new chat message
23
24## Technologies
25
26- Hono - API framework
27- SQLite - Database for storing job postings and chat messages

untitled-3074index.ts8 matches

@adewoleef123•Updated 1 week ago
33});
34
35// API Routes
36const api = new Hono();
37
38// Job posting endpoints
39api.get("/jobs", async (c) => {
40 try {
41 const jobs = await getAllJobs();
47});
48
49api.post("/jobs", async (c) => {
50 try {
51 const body = await c.req.json();
68
69// Chat message endpoints
70api.get("/chat", async (c) => {
71 try {
72 const messages = await getChatMessages();
78});
79
80api.post("/chat", async (c) => {
81 try {
82 const body = await c.req.json();
95});
96
97// Mount API routes
98app.route("/api", api);
99
100// Serve static files

untitled-3074index.js4 matches

@adewoleef123•Updated 1 week ago
113
114 try {
115 const response = await fetch('/api/jobs', {
116 method: 'POST',
117 headers: {
148 if (message && currentUsername) {
149 try {
150 const response = await fetch('/api/chat', {
151 method: 'POST',
152 headers: {
264 if (chatSidebar.classList.contains('translate-x-0')) {
265 try {
266 const response = await fetch('/api/chat');
267 const result = await response.json();
268
291async function fetchJobs() {
292 try {
293 const response = await fetch('/api/jobs');
294 const result = await response.json();
295

untitled-3074types.ts2 matches

@adewoleef123•Updated 1 week ago
18}
19
20// API response types
21export interface ApiResponse<T> {
22 success: boolean;
23 data?: T;

untitled-3074README.md1 match

@adewoleef123•Updated 1 week ago
15## Project Structure
16
17- `/backend/` - Hono API server and database logic
18- `/frontend/` - HTML, CSS, and client-side JavaScript
19- `/shared/` - Types and utilities shared between frontend and backend

token-server1 file match

@kwhinnery_openai•Updated 12 hours ago
Mint tokens to use with the OpenAI Realtime API for WebRTC

book-lookup-notion6 file matches

@nucky•Updated 1 day ago
use google book api to look up bibliographic metadata elements
rapilot330
Kapil01