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=11&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 18916 results for "api"(2802ms)

ValTownValsdk.ts3 matches

@wolf•Updated 20 hours ago
19 return true;
20 } catch (error) {
21 if (error instanceof ValTown.APIError && error.status === 404) {
22 return false;
23 }
61 return targetVal.id;
62 } catch (error) {
63 if (error instanceof ValTown.APIError) {
64 throw new Error(`Failed to resolve Val identifier: ${identifier}`);
65 }
217});
218
219export const sdk = new ValTown({ bearerToken: "VAL_TOWN_API_KEY_1" });

saulyteindex.tsx10 matches

@laurynas•Updated 20 hours ago
175 await fetchWeatherData(locationData.lat, locationData.lon);
176 } else {
177 // Get location from API
178 const locationResponse = await fetch("/api/location");
179 const locationData = await locationResponse.json();
180 setLocation(locationData);
206 }
207
208 const response = await fetch(`/api/weather?lat=${lat}&lon=${lon}`);
209 const data = await response.json();
210
257 // Normalize the query for better search results
258 const normalizedQuery = query.trim();
259 const response = await fetch(`/api/geocode?q=${encodeURIComponent(normalizedQuery)}`);
260 const data = await response.json();
261
272 );
273
274 // Sort API results normally
275 const sortedApiResults = data.results.sort((a: GeocodingResult, b: GeocodingResult) => {
276 const aNameLower = a.name.toLowerCase();
277 const bNameLower = b.name.toLowerCase();
289 });
290
291 // Combine priority locations first, then API results (removing duplicates)
292 const allResults = [
293 ...matchingPriorityLocations,
294 ...sortedApiResults.filter(apiResult =>
295 !matchingPriorityLocations.some(priority =>
296 priority.name === apiResult.name && priority.country === apiResult.country
297 )
298 )
307 queryClient.prefetchQuery({
308 queryKey: ['weather', location.latitude, location.longitude],
309 queryFn: () => fetch(`/api/weather?lat=${location.latitude}&lon=${location.longitude}`).then(res => res.json()),
310 staleTime: 5 * 60 * 1000, // 5 minutes
311 });

saulyteCLAUDE.md13 matches

@laurynas•Updated 20 hours ago
14- **Routing**: TanStack Router for URL state management
15- **Styling**: CSS with responsive grid layouts
16- **Data Source**: Open-Meteo KNMI API (no API key required)
17
18## Project Structure
34- **Hono server** with error unwrapping for better debugging
35- **Static file serving** using Val Town utilities (`serveFile`, `readFile`)
36- **Three main API endpoints**:
37 - `/api/weather?lat={lat}&lon={lon}` - Weather data with photography insights
38 - `/api/location` - Auto-detect location from IP with Amsterdam fallback
39 - `/api/geocode?q={query}` - Search locations by city/area name
40- **Photography scoring algorithm** that calculates 1-10 ratings based on:
41 - Cloud cover percentage (main factor)
57### Core Data Flow
581. **Location Detection**: Auto-detect via IP or manual search/coordinates
592. **Weather Fetch**: Query Open-Meteo KNMI API with comprehensive hourly data
603. **Photography Analysis**: Generate insights with scoring algorithm
614. **UI Rendering**: Display in responsive grid with day/night distinction
145- Text files only (no binary uploads)
146- Serverless Deno environment
147- No Node.js APIs available
148- Cannot use `alert()`, `prompt()`, or `confirm()`
149- Use `return new Response(null, { status: 302, headers: { Location: "/path" }})` for redirects
158- **Error handling**: Let errors bubble up with context rather than catching/logging
159- **Never include secrets** in code - always use environment variables
160- **Prefer official SDKs** over writing API calls directly
161- **Comments**: Only explain complex logic, avoid commenting obvious operations
162- **Complete solutions**: Provide functional implementations, not skeleton code
174 ```
175
176## Data Sources and APIs
177
178- **Weather**: Open-Meteo KNMI API (free, no API key)
179- **Geocoding**: Open-Meteo Geocoding API (free, no API key)
180- **Location**: ip-api.com for IP-based location detection
181- **Fallback**: Amsterdam coordinates (52.3676, 4.9041) if detection fails
182
213```
214
215**Important**: These utilities ONLY run on the server. Pass data to client via HTML injection or API calls.
216
217## Testing and Deployment

firecrawlREADME.md1 match

@charmaine•Updated 20 hours ago
111. `Remix` this val
122. In `Environment Variables` on the val's left sidebar, put in your
13 `FIRECRAWL_API_KEY`
143. Click `Run` on `main.tsx`
154. See the website markdown in the logs below!

TowniePurchaseCreditsRoute.tsx2 matches

@valdottown•Updated 21 hours ago
15 const fetchBalance = async () => {
16 try {
17 const response = await fetch("/api/credit-balance");
18 if (response.ok) {
19 const data = await response.json();
35
36 try {
37 const response = await fetch("/api/purchase-credits", {
38 method: "POST",
39 headers: { "Content-Type": "application/json" },

tanstackReactHonoExampleREADME.md3 matches

@laurynas•Updated 21 hours ago
38```
39
40## API Endpoints
41
42- `GET /` - Serves the React application with initial data
43- `GET /api/messages` - Fetch all messages (JSON)
44- `POST /api/messages` - Create a new message
45- `GET /public/**` - Static assets (CSS, JS, etc.)
46- `/*` - All other routes handled by TanStack Router

tanstackReactHonoExamplequeries.ts2 matches

@laurynas•Updated 21 hours ago
7 queryKey: ["messages"],
8 queryFn: async () => {
9 const response = await fetch("/api/messages");
10 if (!response.ok) {
11 throw new Error("Failed to fetch messages");
25 return useMutation({
26 mutationFn: async (content: string) => {
27 const response = await fetch("/api/messages", {
28 method: "POST",
29 headers: { "Content-Type": "application/json" },

tanstackReactHonoExampleindex.ts3 matches

@laurynas•Updated 21 hours ago
34app.get("/shared/**/*", c => serveFile(c.req.path, import.meta.url));
35
36// API endpoints
37app.get("/api/messages", async (c) => {
38 const messages = await getMessages();
39 return c.json(messages);
40});
41
42app.post("/api/messages", async (c) => {
43 const { content } = await c.req.json();
44

firecrawlmain.tsx1 match

@charmaine•Updated 21 hours ago
4} from "npm:@mendable/firecrawl-js";
5
6const app = new FirecrawlApp({ apiKey: Deno.env.get("FIRECRAWL_API_KEY") });
7
8// Scrape a website

Towniesend-message.ts12 matches

@valdottown•Updated 21 hours ago
48 project,
49 branchId,
50 anthropicApiKey,
51 selectedFiles,
52 images,
54
55 // do we want to allow user-provided tokens still
56 const apiKey = anthropicApiKey || Deno.env.get("ANTHROPIC_API_KEY");
57 const our_api_token = apiKey === Deno.env.get("ANTHROPIC_API_KEY");
58
59 if (our_api_token) {
60 if (await hasInsufficientCredits({ bearerToken })) {
61 return Response.json({
73
74 const rowid = await startTrackingUsage({
75 our_api_token,
76 bearerToken, // will look up the userId from this
77 branch_id: branchId,
82
83 // Initialize PostHog client
84 const projectApiKey = Deno.env.get("POSTHOG_PROJECT_API_KEY");
85
86 let tracedModel;
87
88 if (projectApiKey) {
89 const phClient = new PostHog(projectApiKey, {
90 host: "https://us.i.posthog.com",
91 });
98 const traceId = `townie_${rowid}_${Date.now()}`;
99
100 const anthropic = createAnthropic({ apiKey });
101
102 // Wrap the Anthropic model with PostHog tracing
108 townie_branch_id: branchId,
109 townie_usage_id: rowid,
110 townie_our_api_token: our_api_token,
111 townie_num_images: images?.length || 0,
112 townie_selected_files_count: selectedFiles?.length || 0,
121 } else {
122 // Fallback to regular Anthropic call if PostHog is not configured
123 const anthropic = createAnthropic({ apiKey });
124 tracedModel = anthropic(model);
125 }
271 });
272
273 if (our_api_token) {
274 const stillHasCredits =
275 !(await hasInsufficientCredits({ bearerToken })); // Check for at least 1 cent

beeminder-api4 file matches

@cricks_unmixed4u•Updated 2 hours ago

shippingAPI1 file match

@dynamic_silver•Updated 17 hours ago
apiry
snartapi