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=14&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 20751 results for "api"(3716ms)

fivemain.tsx5 matches

@join•Updated 1 day ago
24 <meta name="viewport" content="width=device-width, initial-scale=1.0">
25 <title>Deconstruction Engine</title>
26 <link rel="preconnect" href="https://fonts.googleapis.com">
27 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
28 <link href="https://fonts.googleapis.com/css2?family=AudioWide&display=swap" rel="stylesheet">
29<style>
30 * {
181<script>
182(function() {
183 const API_URL = '${sourceUrl}';
184 const form = document.getElementById('prompt-form');
185 const input = document.getElementById('prompt-input');
276
277 try {
278 const response = await fetch(API_URL, {
279 method: 'POST',
280 headers: { 'Content-Type': 'application/json' },
315 if (req.method === "POST") {
316 try {
317 const openai = new OpenAI({ apiKey: Deno.env.get("openai") });
318 const body = await req.json();
319 const prompt = body.prompt;

huyhieuREADME.md1 match

@lanly•Updated 1 day ago
15- VS Code Marketplace integration
16
17### HuyHieu API
18
19```

amain.ts2 matches

@flesch•Updated 1 day ago
1import { PollyClient, SynthesizeSpeechCommand } from "npm:@aws-sdk/client-polly";
2
3const BEARER_TOKEN = Deno.env.get("API_TOKEN");
4
5// Domain model: Speech synthesis request
134 }
135
136 // Handle ReadableStream (Node.js style or Web API)
137 if (response.AudioStream && typeof response.AudioStream === "object") {
138 // Try to convert to Uint8Array
14 const auth = new GoogleAuth({
15 credentials,
16 scopes: ["https://www.googleapis.com/auth/documents"],
17 });
18
48 }
49
50 // Insert at the beginning of the document using direct API call
51 const requests = [{
52 insertText: {
58 }];
59
60 const response = await fetch(`https://docs.googleapis.com/v1/documents/${documentId}:batchUpdate`, {
61 method: 'POST',
62 headers: {
69 if (!response.ok) {
70 const errorText = await response.text();
71 throw new Error(`Google Docs API error: ${response.status} ${response.statusText} - ${errorText}`);
72 }
73

Createusersmain.ts1 match

@Liemar•Updated 1 day ago
28
29 try {
30 const res = await fetch(`${ASTRA_BASE_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections`, {
31 method: "POST",
32 headers,

Astramain.ts3 matches

@Liemar•Updated 1 day ago
40 };
41
42 const res = await fetch(`${ASTRA_BASE_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections/${COLLECTION}`, {
43 method: "POST",
44 headers,
59 // ✅ GET /users
60 if (pathname === "/users" && method === "GET") {
61 const res = await fetch(`${ASTRA_BASE_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections/${COLLECTION}`, {
62 method: "GET",
63 headers,
80 log.requestBody = body;
81
82 const res = await fetch(`${ASTRA_BASE_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections/${COLLECTION}`, {
83 method: "POST",
84 headers,

Astramain.ts3 matches

@Liemar•Updated 1 day ago
34 // /users GET
35 if (pathname === "/users" && method === "GET") {
36 const res = await fetch(`${ASTRA_BASE_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections/${COLLECTION}`, {
37 method: "GET",
38 headers,
54 // /users POST
55 if (pathname === "/users" && method === "POST" && body) {
56 const res = await fetch(`${ASTRA_BASE_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections/${COLLECTION}`, {
57 method: "POST",
58 headers,
78 };
79
80 const res = await fetch(`${ASTRA_BASE_URL}/api/rest/v2/namespaces/${KEYSPACE}/collections/${COLLECTION}`, {
81 method: "POST",
82 headers,

crmmain.tsx11 matches

@join•Updated 1 day ago
169<head>
170 <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Franchise CRM Dashboard</title>
171 <link rel="preconnect" href="https://fonts.googleapis.com"><link rel="preconnect" href="https://fonts.gstatic.com" crossorigin><link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&family=Source+Sans+Pro:wght@700;900&display=swap" rel="stylesheet">
172<style>
173 :root { --bg-main: #f8f9fa; --bg-panel: #ffffff; --border-color: #dee2e6; --text-primary: #212529; --text-secondary: #6c757d; --brand-yellow: #ffc72c; --brand-blue: #005eb8; --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05); }
224(function() {
225 const G = (id) => document.getElementById(id); let customers = []; let selectedCustomerId = null; let currentFranchiseId = 1;
226 async function api(action, method = 'POST', body = null) {
227 const url = \`${baseUrl}?action=\${action}\`;
228 const options = { method, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ...body, franchiseId: currentFranchiseId }) };
229 if (method === 'GET') { url += \`&franchiseId=\${currentFranchiseId}\`; delete options.body; }
230 try { const r = await fetch(url, options); if (!r.ok) { const e = await r.json().catch(() => ({})); throw new Error(e.error || 'HTTP ' + r.status); } return r.json(); }
231 catch (e) { console.error('API Error:', e); throw e; }
232 }
233 async function api(action, method = 'POST', body = null) {
234 // CORRECTED: Changed 'const' to 'let' to allow modification.
235 let url = \`${"\${baseUrl}"}?action=\${action}\`;
252 return response.json();
253 } catch (error) {
254 console.error('API call ' + action + ' failed:', error);
255 throw error;
256 }
306 const btn = G('submit-new-customer'); btn.disabled = true; btn.textContent = "Ingesting...";
307 const payload = { customerData: { posId: G('posId').value, name: G('name').value, email: G('email').value, phone: G('phone').value }, transactionData: { date: new Date().toISOString(), total: G('total').value, items: G('items').value.split(',').map(s=>s.trim()), channel: G('channel').value } };
308 try { await api('ingestInteraction', 'POST', payload); location.reload(); }
309 catch (err) { alert("Failed to save: " + err.message); btn.disabled = false; btn.textContent = "Save & Ingest"; }
310 };
312 function renderSeedUI() {
313 G('content-pane').innerHTML = \`<div class="placeholder"><h2>Welcome to the AI CRM</h2><p>The database is empty. Click to populate it with sample data and AI-generated profiles.</p><button id="seed-btn" class="action-btn" style="background:var(--brand-blue); color:white; padding:12px 24px;">Seed Sample Data</button></div>\`;
314 G('seed-btn').addEventListener('click', async (e) => { e.target.disabled = true; e.target.textContent = 'Seeding...'; try { await api('seedDatabase', 'POST'); e.target.textContent = 'Success! Reloading...'; location.reload(); } catch (err) { e.target.disabled = false; e.target.textContent = 'Seed Sample Data'; alert('Failed to seed: ' + err.message); } });
315 }
316 async function loadInitialData() {
317 try {
318 const data = await api('getFranchiseData', 'GET');
319 G('franchise-name').textContent = data.franchise.name; G('franchise-location').textContent = data.franchise.location;
320 customers = data.customers; renderCustomerList();
321 G('analytics-btn').onclick = async (e) => {
322 e.target.disabled = true; e.target.textContent = "Analyzing..."; G('segment-results').innerHTML = 'AI is analyzing...';
323 try { const result = await api('runSegmentation', 'POST'); G('segment-results').innerHTML = result.segments.map(s => \`<div class="detail-card" style="margin:0 0 1rem 0; padding:1rem;"><h4>\${s.name}</h4><p style="font-size:0.85rem">\${s.description}</p></div>\`).join(''); await loadInitialData(); }
324 catch (err) { G('segment-results').innerHTML = 'Error running analysis.'; } finally { e.target.disabled = false; e.target.textContent = "Run AI Segmentation"; }
325 };
334}
335
336// --- API ENDPOINTS & MAIN HANDLER ---
337export default async function(req: Request) {
338 const url = new URL(req.url);
339 const action = url.searchParams.get("action");
340 const openai = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
341 await initializeDatabase();
342 try {

saulytesw.js20 matches

@laurynas•Updated 1 day ago
1const CACHE_NAME = 'kur-saulyte-v1';
2const API_CACHE_NAME = 'kur-saulyte-api-v1';
3
4// Static assets to cache
13];
14
15// API endpoints that can be cached
16const CACHEABLE_APIS = [
17 '/api/weather',
18 '/api/location',
19 '/api/geocode'
20];
21
41 return Promise.all(
42 cacheNames.map((cacheName) => {
43 if (cacheName !== CACHE_NAME && cacheName !== API_CACHE_NAME) {
44 console.log('PWA: Deleting old cache:', cacheName);
45 return caches.delete(cacheName);
58 const requestUrl = new URL(event.request.url);
59
60 // Handle API requests
61 if (CACHEABLE_APIS.some(api => requestUrl.pathname.startsWith(api))) {
62 event.respondWith(handleApiRequest(event.request));
63 return;
64 }
80});
81
82// API request handling - cache with timestamp for freshness
83async function handleApiRequest(request) {
84 const url = new URL(request.url);
85 const cacheKey = `${url.pathname}${url.search}`;
91 if (networkResponse.ok) {
92 // Cache successful responses with timestamp
93 const cache = await caches.open(API_CACHE_NAME);
94 const responseToCache = networkResponse.clone();
95
105
106 await cache.put(cacheKey, responseWithTimestamp);
107 console.log('PWA: API response cached:', cacheKey);
108 return networkResponse;
109 }
113 // Network failed, try cache
114 console.log('PWA: Network failed, trying cache for:', cacheKey);
115 const cache = await caches.open(API_CACHE_NAME);
116 const cachedResponse = await cache.match(cacheKey);
117
122
123 if (cachedAt && parseInt(cachedAt) > thirtyMinutesAgo) {
124 console.log('PWA: Serving fresh cached API response');
125 return cachedResponse;
126 } else {
127 console.log('PWA: Serving stale cached API response');
128 // Return stale data but with a header indicating it's stale
129 return new Response(cachedResponse.body, {
187// Create offline response for different endpoints
188function createOfflineResponse(pathname) {
189 if (pathname.startsWith('/api/weather')) {
190 return new Response(JSON.stringify({
191 error: 'Offline - weather data not available',
197 }
198
199 if (pathname.startsWith('/api/location')) {
200 return new Response(JSON.stringify({
201 lat: 52.3676,
210 }
211
212 if (pathname.startsWith('/api/geocode')) {
213 return new Response(JSON.stringify({
214 results: [],

Townie2system_prompt.txt9 matches

@wolf•Updated 1 day 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:
158- **AI Image:** To inline generate an AI image use: `<img src="https://maxm-imggenurl.web.val.run/the-description-of-your-image" />`
159- **Storage:** DO NOT use the Deno KV module for storage
160- **Browser APIs:** DO NOT use the `alert()`, `prompt()`, or `confirm()` methods
161- **Weather Data:** Use open-meteo for weather data (doesn't require API keys) unless otherwise specified
162- **Error Debugging:** Add `<script src="https://esm.town/v/std/catch"></script>` to HTML to capture client-side errors
163- **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
164- **Environment Variables:** Use `Deno.env.get('keyname')` when you need to, but generally prefer APIs that don't require keys
165- **Imports:** Use `https://esm.sh` for npm and Deno dependencies to ensure compatibility on server and browser
166- **Storage Strategy:** Only use backend storage if explicitly required; prefer simple static client-side sites
200### Backend (Hono) Best Practices
201
202- Hono is the recommended API framework
203- Main entry point should be `backend/index.ts`
204- Do NOT use Hono serveStatic middleware
225 });
226 ```
227- Create RESTful API routes for CRUD operations
228- Always include this snippet at the top-level Hono app to re-throwing errors to see full stack traces:
229 ```ts
262 - For files in the project, use `readFile` helpers
263
2645. **API Design:**
265 - `fetch` handler is the entry point for HTTP vals
266 - Run the Hono app with `export default app.fetch // This is the entry point for HTTP vals`

claude-api1 file match

@ziyanwould•Updated 3 days ago

api-workshop

@danarddanielsjr•Updated 4 days ago
replicate
Run AI with an API
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)