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%22Optional%20title%22?q=api&page=13&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 11753 results for "api"(1910ms)

Towniequeries.tsx5 matches

@pomdtrUpdated 1 day ago
24 user_id = ?
25 AND timestamp > ?
26 AND our_api_token = 1
27 `,
28 [userId, new Date().getTime() - 24 * 60 * 60 * 1000],
54 branch_id,
55 model,
56 our_api_token,
57 num_images,
58}: {
61 branch_id: string;
62 model: string;
63 our_api_token: boolean;
64 num_images: number;
65}) {
73 branch_id,
74 model,
75 our_api_token,
76 num_images
77 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
84 branch_id,
85 model,
86 our_api_token ? 1 : 0,
87 num_images,
88 ],

TowniePreview.tsx1 match

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

TownieLoginRoute.tsx8 matches

@pomdtrUpdated 1 day 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 />

Townieindex.ts2 matches

@pomdtrUpdated 1 day ago
11app.get("*", async (c, next) => {
12 const path = c.req.path;
13 if (path.startsWith("/api/") || c.req.header("Accept")?.includes("application/json")) {
14 return next();
15 }
21});
22
23app.route("/api", backend);
24app.get("/frontend/*", c => {
25 return serveFile(c.req.path, import.meta.url);

TownieHome.tsx5 matches

@pomdtrUpdated 1 day 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>

TownieChatRoute.tsx2 matches

@pomdtrUpdated 1 day ago
63 refetch: () => void;
64}) {
65 const { token, anthropicApiKey } = useAuth();
66 const [images, setImages] = useState<(string|null)[]>([]);
67 const [selectedFiles, setSelectedFiles] = useState<string[]>([]);
81 project,
82 branchId,
83 anthropicApiKey,
84 bearerToken: token,
85 selectedFiles,

Towniequeries.tsx5 matches

@valdottownUpdated 1 day ago
24 user_id = ?
25 AND timestamp > ?
26 AND our_api_token = 1
27 `,
28 [userId, new Date().getTime() - 24 * 60 * 60 * 1000],
54 branch_id,
55 model,
56 our_api_token,
57 num_images,
58}: {
61 branch_id: string;
62 model: string;
63 our_api_token: boolean;
64 num_images: number;
65}) {
73 branch_id,
74 model,
75 our_api_token,
76 num_images
77 ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
84 branch_id,
85 model,
86 our_api_token ? 1 : 0,
87 num_images,
88 ],
45 log(LogLevel.ERROR, operation, status, details);
46
47// Error handling wrapper for Discord API calls
48export async function withErrorHandling<T>(
49 operation: string,
103
104 constructor(retryAfter: number) {
105 super(`Rate limited by Discord API. Retry after ${retryAfter} seconds.`);
106 this.name = "DiscordRateLimitError";
107 this.retryAfter = retryAfter;
58}
59
60// Heartbeat function to check Discord API connection
61async function heartbeat() {
62 const DISCORD_BOT_TOKEN = Deno.env.get("DISCORD_BOT_TOKEN");
63
64 try {
65 const response = await fetch("https://discord.com/api/v10/users/@me", {
66 headers: {
67 Authorization: `Bot ${DISCORD_BOT_TOKEN}`,

Townieusage-dashboard.ts3 matches

@valdottownUpdated 1 day ago
76 SUM(num_images) as total_images
77 FROM ${USAGE_TABLE}
78 WHERE our_api_token = 1
79 GROUP BY user_id, username
80 ORDER BY total_price DESC
258 <th>Finish</th>
259 <th>Images</th>
260 <th>Our API</th>
261 </tr>
262 </thead>
278 <td>${row.finish_reason}</td>
279 <td>${formatNumber(row.num_images)}</td>
280 <td>${formatBoolean(row.our_api_token)}</td>
281 </tr>
282 `).join("")

new-val-api-21 file match

@shouserUpdated 16 mins ago
This is an example of using the API to create a val.

gpt-image-test

@CaptainJackUpdated 16 hours ago
测试 gpt image 的不同 api 能否满足图片生成要求
apiv1
papimark21