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=618&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 11714 results for "api"(1080ms)

exuberantLimeReindeermain.tsx5 matches

@gunisettigokulUpdated 3 months ago
217 } catch (error) {
218 Toastify({
219 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
220 position: "center",
221 duration: 3000,
970 };
971 } else {
972 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
973 const completion = await client.chat.completions.create({
974 messages: [
1095 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1096 <title>CerebrasCoder</title>
1097 <link rel="preconnect" href="https://fonts.googleapis.com" />
1098 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1099 <link
1100 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"
1101 rel="stylesheet"
1102 />
1111 <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."">
1112 <meta property="og:type" content="website">
1113 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1114
1115

cerebras_coderREADME.md2 matches

@gunisettigokulUpdated 3 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`

cerebras_codermain.tsx5 matches

@gunisettigokulUpdated 3 months ago
217 } catch (error) {
218 Toastify({
219 text: "We may have hit our Cerebras Usage limits. Try again later or fork this and use your own API key.",
220 position: "center",
221 duration: 3000,
970 };
971 } else {
972 const client = new Cerebras({ apiKey: Deno.env.get("CEREBRAS_API_KEY") });
973 const completion = await client.chat.completions.create({
974 messages: [
1095 <meta name="viewport" content="width=device-width, initial-scale=1.0">
1096 <title>CerebrasCoder</title>
1097 <link rel="preconnect" href="https://fonts.googleapis.com" />
1098 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1099 <link
1100 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"
1101 rel="stylesheet"
1102 />
1111 <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."">
1112 <meta property="og:type" content="website">
1113 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
1114
1115

rm_ios_testmain.tsx15 matches

@arfanUpdated 3 months ago
255 `);
256
257 // GET /api/apps => return all apps
258 if (request.method === "GET" && request.url.endsWith("/api/apps")) {
259 const result = await sqlite.execute(`SELECT * FROM ${KEY}_apps`);
260 return new Response(JSON.stringify({ apps: result.rows }), {
262 });
263 }
264 // POST /api/apps => create new app
265 else if (request.method === "POST" && request.url.endsWith("/api/apps")) {
266 const app = await request.json();
267 const id = crypto.randomUUID();
274 });
275 }
276 // PUT /api/apps => update existing app
277 else if (request.method === "PUT" && request.url.endsWith("/api/apps")) {
278 const app = await request.json();
279 await sqlite.execute(
285 });
286 }
287 // DELETE /api/apps/:id => delete an app
288 else if (request.method === "DELETE" && /\/api\/apps\/[^/]+$/.test(request.url)) {
289 const segments = request.url.split("/");
290 const id = segments[segments.length - 1];
294 });
295 }
296 // POST /api/apps/import => bulk import (skip duplicates by name)
297 else if (request.method === "POST" && request.url.endsWith("/api/apps/import")) {
298 const { apps } = await request.json();
299 const existing = await sqlite.execute(`SELECT name FROM ${KEY}_apps`);
575 // Get all apps, build categories
576 const loadApps = async () => {
577 const response = await fetch("/api/apps");
578 const data = await response.json();
579 setApps(data.apps);
603 const handleSave = async (updatedApp: App) => {
604 const method = updatedApp.id ? "PUT" : "POST";
605 await fetch("/api/apps", {
606 method,
607 headers: { "Content-Type": "application/json" },
614 const handleDelete = async (id: string) => {
615 if (!window.confirm("Are you sure you want to delete this app?")) return;
616 const resp = await fetch(`/api/apps/${id}`, { method: "DELETE" });
617 if (resp.ok) {
618 await loadApps();
631 // Export
632 const handleExportApps = async () => {
633 const response = await fetch("/api/apps");
634 const data = await response.json();
635 const jsonStr = JSON.stringify(data.apps, null, 2);
652 const text = await file.text();
653 const importedApps = JSON.parse(text);
654 await fetch("/api/apps/import", {
655 method: "POST",
656 headers: { "Content-Type": "application/json" },

emailValHandlerNomain.tsx22 matches

@martinbowlingUpdated 3 months ago
20
212. Set up the required environment variable:
22 - OPENAI_API_KEY: Your OpenAI API key
23
24 Optional environment variable:
25 - MD_API_KEY: Your API key for the markdown extraction service (if available)
26
27 You can set these using Val Town's environment variables: https://docs.val.town/reference/environment-variables/
47
48- PDFs: Text content will be extracted and analyzed
49- Images: Will be analyzed using GPT-4 Vision API
50- Websites: Content will be extracted and converted to markdown for analysis if the markdown extraction service is available
51- Other file types are not currently supported and will be ignored
62// Main controller function
63export default async function emailValHandler(receivedEmail) {
64 const openaiUrl = "https://api.openai.com/v1/chat/completions";
65 const openaiKey = Deno.env.get("OPENAI_API_KEY");
66 const mdApiKey = Deno.env.get("MD_API_KEY");
67 const model = "o1-2024-12-17";
68
82 // Step 3: Process different types of content
83 const { pdfTexts, imageAnalysis } = await processAttachments(attachments, openaiKey, transformedPrompt);
84 const websiteMarkdown = await extractWebsiteMarkdown(links, mdApiKey);
85
86 // Step 4: Create final prompt with all context
125
126// Extract website markdown content
127async function extractWebsiteMarkdown(links, apiKey) {
128 const markdownResults = [];
129 const requestsPerMinute = 5;
145 };
146
147 // Only add headers if API key is available
148 if (apiKey) {
149 fetchOptions.headers = {
150 "Authorization": `Bearer ${apiKey}`,
151 "Content-Type": "application/json",
152 };
170
171// Process image attachments with GPT-4V
172async function analyzeImage(imageAttachment, apiKey, transformedPrompt) {
173 try {
174 const response = await fetch("https://api.openai.com/v1/chat/completions", {
175 method: "POST",
176 headers: {
177 "Content-Type": "application/json",
178 "Authorization": `Bearer ${apiKey}`,
179 },
180 body: JSON.stringify({
214
215// Transform the original prompt using the prompt transformer
216async function transformPrompt(emailText, openaiUrl, apiKey, model) {
217 const promptTransformerText =
218 `You are an AI assistant tasked with transforming user queries into structured research or information requests. Your goal is to take a simple query and expand it into a comprehensive research objective with specific formatting requirements.
288 headers: {
289 "Content-Type": "application/json",
290 Authorization: `Bearer ${apiKey}`,
291 },
292 });
294 const data = await response.json();
295 if (data.error) {
296 throw new Error(`OpenAI API Error: ${data.error.message}`);
297 }
298 return data.choices[0]?.message?.content || emailText;
304
305// Process all attachments (PDFs and Images)
306async function processAttachments(attachments, apiKey, transformedPrompt) {
307 const pdfTexts = [];
308 const imageAnalysis = [];
313 pdfTexts.push(...pdfText);
314 } else if (attachment.type.startsWith("image/")) {
315 const analysis = await analyzeImage(attachment, apiKey, transformedPrompt);
316 imageAnalysis.push({
317 filename: attachment.filename,
383
384// Helper function to send a request to OpenAI
385async function sendRequestToOpenAI(prompt, transformedPrompt, openaiUrl, apiKey, model) {
386 try {
387 // Debug logging for the prompt and transformed prompt
418 headers: {
419 "Content-Type": "application/json",
420 Authorization: `Bearer ${apiKey}`,
421 },
422 });
425 const data = await response.json();
426 if (data.error) {
427 throw new Error(`OpenAI API Error: ${data.error.message}`);
428 }
429 return data.choices[0]?.message?.content || "No response from OpenAI.";

emailValHandlerNoREADME.md3 matches

@martinbowlingUpdated 3 months ago
19
202. Set up the required environment variables:
21 - OPENAI_API_KEY: Your OpenAI API key
22 - MD_API_KEY: Your API key for the markdown extraction service
23
24 You can set these using Val Town's environment variables: https://docs.val.town/reference/environment-variables/
44
45- PDFs: Text content will be extracted and analyzed
46- Images: Will be analyzed using GPT-4 Vision API
47- Websites: Content will be extracted and converted to markdown for analysis
48- Other file types are not currently supported and will be ignored

kanbanTodoListmain.tsx2 matches

@stevekrouseUpdated 3 months ago
499 <title>Task Board</title>
500 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
501 <link rel="preconnect" href="https://fonts.googleapis.com">
502 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
503 <link href="https://fonts.googleapis.com/css2?family=DM+Serif+Text:ital@0;1&family=Dancing+Script:wght@400..700&family=Jersey+10&family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Playwrite+AU+SA:wght@100..400&family=Playwrite+IE+Guides&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&family=Rubik+Vinyl&display=swap" rel="stylesheet">
504 <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" />
505 <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet" />

cerebras_codermain.tsx1 match

@DanapUpdated 3 months ago
20 };
21 } else {
22 const client = new Cerebras({ apiKey: "csk-mn4mrjnj8dx6pe26dfme6v8djjvd65jhedtt464fcxtcfkry" });
23 const completion = await client.chat.completions.create({
24 messages: [

cerebras_coderREADME.md2 matches

@DanapUpdated 3 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`

preciseScarletHerringmain.tsx5 matches

@stevekrouseUpdated 3 months ago
88 // Keep these comments so we remember not to change this
89 const client = new OpenAI({
90 apiKey: Deno.env.get("CEREBRAS_API_KEY"),
91 baseURL: "https://api.cerebras.ai/v1",
92 });
93
101 return Response.json({ message: generatedMessage });
102 } catch (error) {
103 console.error("Error calling Cerebras API:", error);
104
105 if (error.status === 429) {
106 return Response.json({ error: "Cerebras API rate limit reached. Please try again later." }, { status: 429 });
107 } else {
108 return Response.json({ error: `API Error: ${error.message}` }, { status: 500 });
109 }
110 }

gpt-image-test

@CaptainJackUpdated 10 mins ago
测试 gpt image 的不同 api 能否满足图片生成要求

new-val-api-21 file match

@shouserUpdated 1 day ago
This is an example of using the API to create a val.
papimark21
socialdata
Affordable & reliable alternative to Twitter API: ➡️ Access user profiles, tweets, followers & timeline data in real-time ➡️ Monitor profiles with nearly instant alerts for new tweets, follows & profile updates ➡️ Simple integration