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/$%7Bsuccess?q=api&page=3&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 14224 results for "api"(562ms)

Gardenonindex.html8 matches

@Llad•Updated 5 hours ago
207 const plantList = document.getElementById('plant-list');
208 const noPlantMessage = document.getElementById('no-plants-message');
209 const mapInstructions = document.getElementById('map-instructions');
210
211 // Form elements
231 async function fetchPlants() {
232 try {
233 const response = await fetch('/api/plants');
234 plants = await response.json();
235
356 function startAddingPlant() {
357 isAddingPlant = true;
358 mapInstructions.textContent = 'Tap on the map to place your plant';
359 addPlantBtn.classList.add('bg-gray-500');
360 addPlantBtn.classList.remove('bg-green-600', 'hover:bg-green-700');
364 function cancelAddingPlant() {
365 isAddingPlant = false;
366 mapInstructions.textContent = 'Tap anywhere on the map to add a plant';
367 addPlantBtn.classList.remove('bg-gray-500');
368 addPlantBtn.classList.add('bg-green-600', 'hover:bg-green-700');
406 addPlantBtn.classList.remove('bg-gray-500');
407 addPlantBtn.classList.add('bg-green-600', 'hover:bg-green-700');
408 mapInstructions.textContent = 'Tap anywhere on the map to add a plant';
409 }
410
416 if (plantData.id) {
417 // Update existing plant
418 response = await fetch(`/api/plants/${plantData.id}`, {
419 method: 'PUT',
420 headers: { 'Content-Type': 'application/json' },
423 } else {
424 // Create new plant
425 response = await fetch('/api/plants', {
426 method: 'POST',
427 headers: { 'Content-Type': 'application/json' },
454
455 try {
456 const response = await fetch(`/api/plants/${id}`, {
457 method: 'DELETE'
458 });

Gardenonindex.ts7 matches

@Llad•Updated 5 hours ago
35initDatabase();
36
37// API Routes
38// Get all plants
39app.get("/api/plants", async (c) => {
40 const plantResults = await sqlite.execute(`SELECT * FROM ${TABLE_NAME} ORDER BY id DESC`);
41 return c.json(plantResults.rows);
43
44// Get database info (for admin purposes)
45app.get("/api/admin/db", async (c) => {
46 // Get table schema
47 const schema = await sqlite.execute(`PRAGMA table_info(${TABLE_NAME})`);
63
64// Get a specific plant
65app.get("/api/plants/:id", async (c) => {
66 const id = c.req.param("id");
67 const plants = await sqlite.execute(`SELECT * FROM ${TABLE_NAME} WHERE id = ?`, [id]);
75
76// Create a new plant
77app.post("/api/plants", async (c) => {
78 const body = await c.req.json();
79
100
101// Update a plant
102app.put("/api/plants/:id", async (c) => {
103 const id = c.req.param("id");
104 const body = await c.req.json();
132
133// Delete a plant
134app.delete("/api/plants/:id", async (c) => {
135 const id = c.req.param("id");
136

BionicReaderindex.html2 matches

@tusharGoyal•Updated 6 hours ago
176 try {
177 // Send file to server
178 const response = await fetch('/api/process', {
179 method: 'POST',
180 body: formData
207 async function setViewSourceLink() {
208 try {
209 const response = await fetch('/api/project-info');
210 const projectInfo = await response.json();
211

BionicReaderpdf_viewer.html1 match

@tusharGoyal•Updated 6 hours ago
370
371 // Fetch the file from the server
372 const response = await fetch(`/api/files/${fileId}`);
373 if (!response.ok) {
374 if (response.status === 404) {

vibeCoding_PLPutils.js5 matches

@Danchi•Updated 7 hours ago
1// Shared utility functions for the Ultimate Animated Storefront Builder
2
3// API utility functions
4class ApiClient {
5 constructor(baseUrl = '') {
6 this.baseUrl = baseUrl;
31 return data;
32 } catch (error) {
33 console.error('API request failed:', error);
34 throw error;
35 }
552 // Node.js environment
553 module.exports = {
554 ApiClient,
555 AnimationUtils,
556 StorageUtils,
564 // Browser environment
565 window.StorefrontUtils = {
566 ApiClient,
567 AnimationUtils,
568 StorageUtils,

vibeCoding_PLPtypes.js13 matches

@Danchi•Updated 7 hours ago
212};
213
214// API endpoints
215const apiEndpoints = {
216 stores: '/api/stores',
217 products: '/api/stores/{storeId}/products',
218 transactions: '/api/stores/{storeId}/transactions',
219 categories: '/api/stores/{storeId}/categories',
220 dashboard: '/api/stores/{storeId}/dashboard',
221 financialHealth: '/api/stores/{storeId}/financial-health',
222 voiceProcess: '/api/voice/process',
223 receiptProcess: '/api/receipt/process',
224 demoSeed: '/api/demo/seed'
225};
226
304 voicePatterns,
305 chartConfigs,
306 apiEndpoints,
307 formatCurrency,
308 formatDate,
330 voicePatterns,
331 chartConfigs,
332 apiEndpoints,
333 formatCurrency,
334 formatDate,

vibeCoding_PLPapp.js5 matches

@Danchi•Updated 7 hours ago
31
32 // Try to get existing stores first
33 const storesResponse = await fetch('/api/stores');
34 const storesResult = await storesResponse.json();
35
54 this.updateLoadingState();
55
56 const response = await fetch('/api/demo/seed', { method: 'POST' });
57 const result = await response.json();
58
76 async loadDashboardData(storeId) {
77 try {
78 const response = await fetch(`/api/stores/${storeId}/dashboard`);
79 const result = await response.json();
80
1013
1014 try {
1015 const response = await fetch('/api/voice/process', {
1016 method: 'POST',
1017 headers: { 'Content-Type': 'application/json' },
1026 if (result.success && !result.data.needs_clarification) {
1027 // Create transaction from voice input
1028 const transactionResponse = await fetch(`/api/stores/${this.currentStore.id}/transactions`, {
1029 method: 'POST',
1030 headers: { 'Content-Type': 'application/json' },

vibeCoding_PLPapi.py37 matches

@Danchi•Updated 7 hours ago
1from fastapi import APIRouter, HTTPException, Depends
2from typing import List, Optional
3import openai
8from database.models import (
9 Store, StoreCreate, Product, ProductCreate, Transaction, TransactionCreate,
10 Category, CategoryCreate, FinancialHealth, DashboardData, ApiResponse,
11 VoiceProcessRequest, VoiceProcessResponse, ReceiptProcessRequest, ReceiptProcessResponse
12)
13
14router = APIRouter()
15
16# Demo user ID for this prototype
18
19# OpenAI configuration
20openai.api_key = os.getenv('OPENAI_API_KEY')
21
22# Health check
26
27# Store routes
28@router.get("/stores", response_model=ApiResponse)
29async def get_stores(db = Depends(get_db_connection)):
30 try:
38 stores.append(store_data)
39
40 return ApiResponse(success=True, data=stores)
41 except Exception as e:
42 raise HTTPException(status_code=500, detail=str(e))
43
44@router.post("/stores", response_model=ApiResponse)
45async def create_store(store_data: StoreCreate, db = Depends(get_db_connection)):
46 try:
63 # Get the created store
64 store = await get_store_by_id(store_id, db)
65 return ApiResponse(success=True, data=store)
66 except Exception as e:
67 raise HTTPException(status_code=500, detail=str(e))
68
69@router.get("/stores/{store_id}", response_model=ApiResponse)
70async def get_store(store_id: int, db = Depends(get_db_connection)):
71 try:
72 store = await get_store_by_id(store_id, db)
73 return ApiResponse(success=True, data=store)
74 except Exception as e:
75 raise HTTPException(status_code=500, detail=str(e))
76
77# Dashboard data
78@router.get("/stores/{store_id}/dashboard", response_model=ApiResponse)
79async def get_dashboard_data(store_id: int, db = Depends(get_db_connection)):
80 try:
106 }
107
108 return ApiResponse(success=True, data=dashboard_data)
109 except Exception as e:
110 raise HTTPException(status_code=500, detail=str(e))
111
112# Product routes
113@router.get("/stores/{store_id}/products", response_model=ApiResponse)
114async def get_products(store_id: int, db = Depends(get_db_connection)):
115 try:
116 products = await get_products_by_store_id(store_id, db)
117 return ApiResponse(success=True, data=products)
118 except Exception as e:
119 raise HTTPException(status_code=500, detail=str(e))
120
121@router.post("/stores/{store_id}/products", response_model=ApiResponse)
122async def create_product(store_id: int, product_data: ProductCreate, db = Depends(get_db_connection)):
123 try:
145 # Get the created product
146 product = await get_product_by_id(product_id, db)
147 return ApiResponse(success=True, data=product)
148 except Exception as e:
149 raise HTTPException(status_code=500, detail=str(e))
150
151# Transaction routes
152@router.get("/stores/{store_id}/transactions", response_model=ApiResponse)
153async def get_transactions(store_id: int, limit: int = 50, db = Depends(get_db_connection)):
154 try:
155 transactions = await get_transactions_by_store_id(store_id, db, limit)
156 return ApiResponse(success=True, data=transactions)
157 except Exception as e:
158 raise HTTPException(status_code=500, detail=str(e))
159
160@router.post("/stores/{store_id}/transactions", response_model=ApiResponse)
161async def create_transaction(store_id: int, transaction_data: TransactionCreate, db = Depends(get_db_connection)):
162 try:
192 # Get the created transaction
193 transaction = await get_transaction_by_id(transaction_id, db)
194 return ApiResponse(success=True, data=transaction)
195 except Exception as e:
196 raise HTTPException(status_code=500, detail=str(e))
197
198# Voice input processing
199@router.post("/voice/process", response_model=ApiResponse)
200async def process_voice_input(request: VoiceProcessRequest):
201 try:
202 if not openai.api_key:
203 raise HTTPException(status_code=500, detail="OpenAI API key not configured")
204
205 response = openai.ChatCompletion.create(
226 import json
227 parsed_data = json.loads(response_text)
228 return ApiResponse(success=True, data=parsed_data)
229 except json.JSONDecodeError:
230 return ApiResponse(
231 success=True,
232 data={
239
240# Receipt processing with AI
241@router.post("/receipt/process", response_model=ApiResponse)
242async def process_receipt(request: ReceiptProcessRequest):
243 try:
244 if not openai.api_key:
245 raise HTTPException(status_code=500, detail="OpenAI API key not configured")
246
247 response = openai.ChatCompletion.create(
277 parsed_data = json.loads(response_text)
278
279 return ApiResponse(success=True, data=parsed_data)
280 except Exception as e:
281 raise HTTPException(status_code=500, detail=str(e))
282
283# Financial health
284@router.get("/stores/{store_id}/financial-health", response_model=ApiResponse)
285async def get_financial_health(store_id: int, days: int = 30, db = Depends(get_db_connection)):
286 try:
287 health = await calculate_financial_health(store_id, db, days)
288 return ApiResponse(success=True, data=health)
289 except Exception as e:
290 raise HTTPException(status_code=500, detail=str(e))
291
292# Category routes
293@router.get("/stores/{store_id}/categories", response_model=ApiResponse)
294async def get_categories(store_id: int, db = Depends(get_db_connection)):
295 try:
296 categories = await get_categories_by_store_id(store_id, db)
297 return ApiResponse(success=True, data=categories)
298 except Exception as e:
299 raise HTTPException(status_code=500, detail=str(e))
300
301@router.post("/stores/{store_id}/categories", response_model=ApiResponse)
302async def create_category(store_id: int, category_data: CategoryCreate, db = Depends(get_db_connection)):
303 try:
319 # Get the created category
320 category = await get_category_by_id(category_id, db)
321 return ApiResponse(success=True, data=category)
322 except Exception as e:
323 raise HTTPException(status_code=500, detail=str(e))
324
325# Demo data seeding
326@router.post("/demo/seed", response_model=ApiResponse)
327async def seed_demo_data(db = Depends(get_db_connection)):
328 try:
429 await create_transaction(store_id, transaction, db)
430
431 return ApiResponse(
432 success=True,
433 data={"store": store, "categories": categories, "products": products},

vibeCoding_PLPmodels.py2 matches

@Danchi•Updated 7 hours ago
147 error: Optional[str] = None
148
149# API Response Models
150class ApiResponse(BaseModel):
151 success: bool
152 data: Optional[Any] = None

vibeCoding_PLPrequirements.txt1 match

@Danchi•Updated 7 hours ago
1fastapi==0.104.1
2uvicorn==0.24.0
3mysql-connector-python==8.2.0

book-lookup5 file matches

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

new-val-api-demo

@shouser•Updated 3 days ago
This is an example of using the API to create a val.
snartapi
mux
Your friendly, neighborhood video API.