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=915&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 21177 results for "api"(8546ms)

Townie-02queries.tsx5 matches

@jxnblk•Updated 1 month ago
24 user_id = ?
25 AND timestamp > ?
26 AND our_api_token = 1
27 `,
28 [userId, new Date().getTime() - 24 * 60 * 60 * 1000],
108 branch_id,
109 model,
110 our_api_token,
111 num_images,
112}: {
115 branch_id: string;
116 model: string;
117 our_api_token: boolean;
118 num_images: number;
119}) {
127 branch_id,
128 model,
129 our_api_token,
130 num_images
131 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
138 branch_id,
139 model,
140 our_api_token ? 1 : 0,
141 num_images,
142 ],

Townie-02Preview.tsx1 match

@jxnblk•Updated 1 month ago
90 value={customPath}
91 onChange={handlePathChange}
92 placeholder="Path (e.g., /api/data)"
93 />
94 </div>

Townie-02LoginRoute.tsx8 matches

@jxnblk•Updated 1 month ago
8 const { isAuthenticated, authenticate, error } = useAuth();
9 const [tokenValue, setTokenValue] = useState("");
10 const [apiKey, setApiKey] = useState("");
11 // const [invalid, setInvalid] = useState(""); // TODO
12
13 const handleSubmit = (e) => {
14 e.preventDefault();
15 authenticate(tokenValue, apiKey);
16 };
17
36 >
37 <div>
38 <label htmlFor="valtown-token" className="label">Val Town API Token</label>
39 <div style={{ fontSize: "0.8em", color: "#666" }}>
40 <p>
41 <a href="https://www.val.town/settings/api/new" target="_blank" rel="noreferrer">
42 Create a Val Town token here
43 </a>
58 </div>
59 <div>
60 <label htmlFor="anthropic-api-key" className="label">Anthropic API Key (optional)</label>
61 <input
62 type="password"
63 id="anthropic-api-key"
64 name="anthropic-key"
65 value={apiKey}
66 onChange={e => {
67 setApiKey(e.target.value);
68 }}
69 />

Townie-02index.ts7 matches

@jxnblk•Updated 1 month 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-02index.ts5 matches

@jxnblk•Updated 1 month 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-02Home.tsx5 matches

@jxnblk•Updated 1 month ago
42 </h2>
43 <ol>
44 <li>Login with your Val Town API token (with projects:read, projects:write, user:read permissions)</li>
45 <li>Select a project to work on</li>
46 <li>Chat with Claude about your code</li>
79 </div>
80 <h3>Cost Tracking</h3>
81 <p>See estimated API usage costs for each interaction</p>
82 </div>
83 </section>
92 <ul>
93 <li>React frontend with TypeScript</li>
94 <li>Hono API server backend</li>
95 <li>Web Audio API for sound notifications</li>
96 <li>AI SDK for Claude integration</li>
97 </ul>
98 <p>
99 The application proxies requests to the Anthropic API and Val Town API, allowing Claude to view and edit your
100 project files directly.
101 </p>

cerebras_coderREADME.md2 matches

@poarox•Updated 1 month ago
6
71. Sign up for [Cerebras](https://cloud.cerebras.ai/)
82. Get a Cerebras API Key
93. Save it in a [Val Town environment variable](https://www.val.town/settings/environment-variables) called `CEREBRAS_API_KEY`
10
11# Todos

cerebras_codermain.tsx5 matches

@poarox•Updated 1 month ago
212 } catch (error) {
213 Toastify({
214 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
215 position: "center",
216 duration: 3000,
971 };
972 } else {
973 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
974 const completion = await client.chat.completions.create({
975 messages: [
1096 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1097 <title>CerebrasCoder</title>
1098 <link rel="preconnect" href="https://fonts.googleapis.com" />
1099 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1100 <link
1101 href="https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap"
1102 rel="stylesheet"
1103 />
1112 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1113 <meta property="og:type" content="website">
1114 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1115
1116

ValTown-Package-Trackerindex.html2 matches

@jhiller•Updated 1 month ago
151 async function loadDevices() {
152 try {
153 const response = await fetch('/api/devices');
154 const devices = await response.json();
155
175 try {
176 const deviceId = deviceSelector.value;
177 const url = deviceId ? `/api/locations?deviceId=${deviceId}` : '/api/locations';
178
179 const response = await fetch(url);

ValTown-Package-Trackerindex.ts22 matches

@jhiller•Updated 1 month ago
40
41// Debug endpoint to check system status
42app.get("/api/debug/status", async (c) => {
43 try {
44 // Check database connection
93app.get("/frontend/*", (c) => serveFile(c.req.path, import.meta.url));
94
95// API endpoint to receive ChirpStack payloads
96app.post("/api/location", async (c) => {
97 console.log("[INGEST] Received payload request");
98
186});
187
188// API endpoint to get location history
189app.get("/api/locations", async (c) => {
190 console.log("[API] Fetching location history");
191
192 try {
193 const deviceId = c.req.query("deviceId");
194 if (deviceId) {
195 console.log(`[API] Filtering locations by device ID: ${deviceId}`);
196 } else {
197 console.log("[API] Fetching all locations (no device filter)");
198 }
199 const { rows } = await getLocationHistory(deviceId);
203 );
204 console.log(
205 `[API] Retrieved ${rows.length} total, ${filtered.length} in North America`
206 );
207 return c.json(filtered);
208
209 } catch (error) {
210 console.error("[API] Error fetching location history:", error);
211 return c.json({
212 error: "Database error",
217});
218
219// API endpoint to get a specific location
220app.get("/api/locations/:id", async (c) => {
221 try {
222 const idParam = c.req.param("id");
223 console.log(`[API] Fetching location with ID: ${idParam}`);
224
225 const id = parseInt(idParam);
226 if (isNaN(id)) {
227 console.error(`[API] Invalid location ID: ${idParam}`);
228 return c.json({
229 error: "Invalid parameter",
234 const location = await getLocationById(id);
235 if (!location) {
236 console.log(`[API] Location not found with ID: ${id}`);
237 return c.json({
238 error: "Not found",
241 }
242
243 console.log(`[API] Successfully retrieved location with ID: ${id}`);
244 return c.json(location);
245 } catch (error) {
246 console.error(`[API] Error fetching location:`, error);
247 return c.json({
248 error: "Database error",
253});
254
255// API endpoint to get list of devices
256app.get("/api/devices", async (c) => {
257 console.log("[API] Fetching device list");
258
259 try {
260 const devices = await getDevices();
261 console.log(`[API] Successfully retrieved ${devices.rows.length} devices`);
262 return c.json(devices.rows);
263 } catch (error) {
264 console.error("[API] Error fetching devices:", error);
265 return c.json({
266 error: "Database error",

github-api8 file matches

@cricks_unmixed4u•Updated 9 hours ago
Very incomplete collection of useful GitHub API adapters

myAPiKey

@Kix111•Updated 12 hours ago
Kapil01
apiv1