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=366&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 4592 results for "api"(906ms)

AlwaysHeregoogleOAuth.ts2 matches

@varun1352Updated 1 month ago
15
16 // Exchange code for tokens
17 const tokenResponse = await fetch("https://oauth2.googleapis.com/token", {
18 method: "POST",
19 headers: { "Content-Type": "application/x-www-form-urlencoded" },
30
31 // Fetch user info
32 const userInfoResponse = await fetch("https://www.googleapis.com/oauth2/v3/userinfo", {
33 headers: { Authorization: `Bearer ${access_token}` },
34 });

AlwaysHereuser.ts1 match

@varun1352Updated 1 month ago
5const user = new Hono();
6
7// GET /api/user?uid=123
8user.get("/", async (c) => {
9 const userId = c.req.query("uid");

AlwaysHererecordings.ts2 matches

@varun1352Updated 1 month ago
5const recordings = new Hono();
6
7// 🎙️ POST /api/recordings - Save a new recording
8recordings.post("/", async (c) => {
9 const { uid, location } = await c.req.json();
21});
22
23// 🎙️ GET /api/recordings?uid={uid} - Fetch user recordings
24recordings.get("/", async (c) => {
25 const uid = c.req.query("uid");

AlwaysHerechat.ts2 matches

@varun1352Updated 1 month ago
21 return c.json({ reply: message });
22 } catch (error) {
23 console.error("Chat API Error:", error);
24 return c.json({ error: "Internal Server Error" }, 500);
25 }
39 return c.json(rows);
40 } catch (error) {
41 console.error("Chat History API Error:", error);
42 return c.json({ error: "Internal Server Error" }, 500);
43 }

frontierScannersite.http.tsx4 matches

@wolfUpdated 1 month ago
4import { Promo } from "./scanner.http.tsx";
5
6const API_URL = "https://wolf--63fba038059911f091d7569c3dd06744.web.val.run/";
7
8function CouponCodeSection() {
93
94 useEffect(() => {
95 fetch(API_URL)
96 .then((response) => response.json())
97 .then((data) => {
99 setPromos(data.promos);
100 } else {
101 throw new Error("API returned unsuccessful response");
102 }
103 setLoading(false);
145 <div className="mt-8 text-center text-sm text-gray-500">
146 <p>
147 Data sourced from <a href={API_URL}>Frontier Airlines API</a>
148 </p>
149 <a

forky_1742582577934App.tsx11 matches

@charmaineUpdated 1 month ago
4export function App() {
5 const [projectUrl, setProjectUrl] = useState("");
6 const [apiToken, setApiToken] = useState("");
7 const [loading, setLoading] = useState(false);
8 const [message, setMessage] = useState("");
21 }
22
23 if (!apiToken.trim()) {
24 throw new Error("API Token is required");
25 }
26
28 method: "POST",
29 headers: {
30 "Authorization": `Bearer ${apiToken}`,
31 "Content-Type": "application/json",
32 },
63 value={projectUrl}
64 onChange={(e) => setProjectUrl(e.target.value)}
65 placeholder="https://api.val.town/v1/projects/..."
66 className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
67 />
69
70 <div>
71 <label htmlFor="apiToken" className="block text-sm font-medium text-gray-700 mb-1">
72 Val Town API Token (project read + write permissions)
73 </label>
74 <input
75 id="apiToken"
76 type="password"
77 value={apiToken}
78 onChange={(e) => setApiToken(e.target.value)}
79 placeholder="Enter your API token"
80 className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
81 />

forky_1742582577934index.ts2 matches

@charmaineUpdated 1 month ago
223app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
224
225// Add your API routes here
226// app.get("/api/data", c => c.json({ hello: "world" }));
227
228// Unwrap and rethrow Hono errors as the original error

import_from_githubindex.ts9 matches

@shouserUpdated 1 month ago
99 const parsedUrl = new URL(url);
100
101 // Handle both github.com URLs and API URLs
102 if (!parsedUrl.hostname.includes("github.com")) {
103 throw new Error("Not a GitHub URL");
132
133 try {
134 // GitHub API URL for repo contents
135 const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`;
136 console.log(`Fetching from: ${apiUrl}`);
137
138 const response = await fetch(apiUrl, {
139 headers: {
140 "Accept": "application/vnd.github.v3+json",
144
145 if (!response.ok) {
146 throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
147 }
148
165 }
166 } else if (item.content && item.encoding === "base64") {
167 // Some API responses include base64 encoded content
168 content = Buffer.from(item.content, "base64").toString("utf8");
169 } else {
379app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
380
381// Add your API routes here
382// app.get("/api/data", c => c.json({ hello: "world" }));
383
384// Unwrap and rethrow Hono errors as the original error

forky_1742579787862App.tsx11 matches

@shouserUpdated 1 month ago
4export function App() {
5 const [projectUrl, setProjectUrl] = useState("");
6 const [apiToken, setApiToken] = useState("");
7 const [loading, setLoading] = useState(false);
8 const [message, setMessage] = useState("");
21 }
22
23 if (!apiToken.trim()) {
24 throw new Error("API Token is required");
25 }
26
28 method: "POST",
29 headers: {
30 "Authorization": `Bearer ${apiToken}`,
31 "Content-Type": "application/json",
32 },
63 value={projectUrl}
64 onChange={(e) => setProjectUrl(e.target.value)}
65 placeholder="https://api.val.town/v1/projects/..."
66 className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
67 />
69
70 <div>
71 <label htmlFor="apiToken" className="block text-sm font-medium text-gray-700 mb-1">
72 Val Town API Token (project read + write permissions)
73 </label>
74 <input
75 id="apiToken"
76 type="password"
77 value={apiToken}
78 onChange={(e) => setApiToken(e.target.value)}
79 placeholder="Enter your API token"
80 className="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-purple-500"
81 />

forky_1742579787862index.ts2 matches

@shouserUpdated 1 month ago
223app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
224
225// Add your API routes here
226// app.get("/api/data", c => c.json({ hello: "world" }));
227
228// Unwrap and rethrow Hono errors as the original error

PassphraseAPI2 file matches

@wolfUpdated 2 days ago

openapi2 file matches

@stevekrouseUpdated 4 days ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
fiberplane
Purveyors of Hono tooling, API Playground enthusiasts, and creators of 🪿 HONC 🪿 (https://honc.dev)