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=613&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 10974 results for "api"(1745ms)

95}
96
97async function createApiInstance(config: Config) {
98 const api = axios.create({
99 baseURL: config.baseUrl,
100 headers: {
106 },
107 });
108 return api;
109}
110
111async function authenticate(api: any, config: Config): Promise<void> {
112 const loginResponse = await api.post("/api/login", {
113 email: config.email,
114 password: config.password,
119 }
120
121 const saveAuthResponse = await api.post("/api/auth/saveAuth", {
122 authorizationToken: loginResponse.data.authorizationToken,
123 });
139 }
140
141 api.defaults.headers["X-Xsrf-Token"] = xsrfToken;
142 api.defaults.headers["Cookie"] = [
143 `accessToken=${accessToken}`,
144 `xsrfToken=${xsrfToken}`,
149}
150
151async function getActiveApps(api: any) {
152 const response = await api.get("/api/pages", {
153 params: {
154 mobileAppsOnly: false,
158 const apps = response.data;
159 if (!apps || !apps.pages || !apps.folders) {
160 throw new Error("Invalid response format from apps API");
161 }
162
176}
177
178async function downloadApp(api: any, app: any, zip: JSZip) {
179 try {
180 console.log(`Downloading app: ${app.name}`);
181 if (!app.uuid) { throw new Error("App UUID is missing"); }
182
183 const response = await api.post(`/api/pages/uuids/${app.uuid}/export`);
184 const exportData = response.data;
185
201}
202
203async function getWorkflows(api: any) {
204 const response = await api.get("/api/workflow/");
205 const workflows = response.data;
206
207 if (!workflows || !workflows.workflowsMetadata) {
208 throw new Error("Invalid response format from workflows API");
209 }
210
212}
213
214async function downloadWorkflow(api: any, workflow: any, zip: JSZip) {
215 try {
216 if (!workflow.id || !workflow.name) {
220
221 console.log(`Downloading workflow: ${workflow.name}`);
222 const response = await api.post("/api/workflow/export", {
223 workflowId: workflow.id,
224 branchName: "",
329 const zip = new JSZip();
330
331 // Create and authenticate API instance
332 const api = await createApiInstance(config);
333 await authenticate(api, config);
334
335 const [activeApps, workflows] = await Promise.all([
336 getActiveApps(api),
337 getWorkflows(api),
338 ]);
339
343 // Download all apps and workflows in parallel
344 await Promise.all([
345 ...activeApps.map(app => downloadApp(api, app, zip)),
346 ...workflows.map(workflow => downloadWorkflow(api, workflow, zip)),
347 ]);
348

Test00_getModelBuildermain.tsx1 match

@lisazzUpdated 4 months ago
8
9 // 3. 由於 Val Town 不支持直接訪問環境變量,
10 // 我們將修改方法以要求傳遞 API 密鑰
11 const args = extend({
12 callbacks: options?.verbose !== false ? [] : undefined

specialBlueGophermain.tsx1 match

@jeffreyyoungUpdated 4 months ago
3
4const replicate = new Replicate({
5 auth: Deno.env.get("REPLICATE_API_KEY"),
6});
7

sophisticatedOliveFinchREADME.md2 matches

@zananowshadUpdated 4 months 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

sophisticatedOliveFinchmain.tsx5 matches

@zananowshadUpdated 4 months 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,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1149 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1150 <title>CerebrasCoder</title>
1151 <link rel="preconnect" href="https://fonts.googleapis.com" />
1152 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153 <link
1154 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"
1155 rel="stylesheet"
1156 />
1165 <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."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169

MILLENCHATmain.tsx12 matches

@LucasMillenUpdated 4 months ago
2// {
3// "name": "AI Chat Assistant",
4// "description": "A chat assistant using OpenAI's API",
5// "permissions": ["env"]
6// }
89
90async function callOpenAI(userMessage: string): Promise<string> {
91 const apiKey = Deno.env.get("OPENAI_API_KEY");
92
93 if (!apiKey) {
94 throw new Error("OpenAI API key is not configured. Please set the OPENAI_API_KEY environment variable.");
95 }
96
97 try {
98 const response = await fetch('https://api.openai.com/v1/chat/completions', {
99 method: 'POST',
100 headers: {
101 'Authorization': `Bearer ${apiKey}`,
102 'Content-Type': 'application/json'
103 },
117 if (!response.ok) {
118 const errorBody = await response.text();
119 throw new Error(`OpenAI API error: ${response.status} - ${errorBody}`);
120 }
121
124 "I'm not sure how to respond to that.";
125 } catch (error) {
126 console.error("OpenAI API Call Error:", error);
127 throw error;
128 }
279
280export default async function server(request: Request): Promise<Response> {
281 // Check if OpenAI API key is configured
282 const apiKey = Deno.env.get("OPENAI_API_KEY");
283
284 if (!apiKey) {
285 return new Response(`
286 <!DOCTYPE html>
313 <div class="error-container">
314 <h1>🚨 Configuration Error</h1>
315 <p>OpenAI API key is not configured. Please set the OPENAI_API_KEY environment variable.</p>
316 <p>Contact the val owner to resolve this issue.</p>
317 </div>

STARTER_PROMPTSmain.tsx1 match

@uran69Updated 4 months ago
12 },
13 {
14 prompt: "weather dashboard for nyc using open-meteo API for NYC with icons",
15 title: "Weather App",
16 code:

intimatePinkMoleREADME.md2 matches

@uran69Updated 4 months 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

intimatePinkMolemain.tsx5 matches

@uran69Updated 4 months 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,
1024 };
1025 } else {
1026 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
1027 const completion = await client.chat.completions.create({
1028 messages: [
1149 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1150 <title>CerebrasCoder</title>
1151 <link rel="preconnect" href="https://fonts.googleapis.com" />
1152 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1153 <link
1154 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"
1155 rel="stylesheet"
1156 />
1165 <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."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1168
1169

luminousAquamarineChickadeeREADME.md2 matches

@uran69Updated 4 months 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

daily-advice-app1 file match

@dcm31Updated 2 days ago
Random advice app using Advice Slip API

gptApiTemplate1 file match

@charmaineUpdated 3 days ago
apiv1
papimark21