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=80&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 12813 results for "api"(1289ms)

parallelmain.ts10 matches

@salon•Updated 3 days ago
562 }
563
564 const apiRequestBody: any = { model, messages: messagesPayload };
565 if (typeof params.temperature === "number") apiRequestBody.temperature = params.temperature;
566 if (typeof params.max_tokens === "number" && params.max_tokens > 0)
567 apiRequestBody.max_tokens = Math.floor(params.max_tokens);
568
569 log("INFO", "OpenAiCallTool", "Making OpenAI chat completion call.", {
576
577 try {
578 const completion = await openaiClient.chat.completions.create(apiRequestBody);
579 if (!completion?.choices?.length) {
580 log("WARN", "OpenAiCallTool", "OpenAI response empty/unexpected.", { response: completion });
583 return { mandateId, correlationId: taskId, payload: { result: completion } };
584 } catch (e: any) {
585 log("ERROR", "OpenAiCallTool", "OpenAI API call failed.", e);
586 const errMsg = e.response?.data?.error?.message || e.error?.message || e.message || "Unknown OpenAI API error";
587 return { mandateId, correlationId: taskId, payload: { result: null }, error: errMsg };
588 }
701 const { mandateId, taskId, payload } = input;
702 const { log } = context;
703 log("INFO", "ScrapeEmails", `Scraping emails for ${payload.businesses?.length ?? 0} sites.`);
704
705 if (!payload?.businesses || !Array.isArray(payload.businesses)) {
753 await delay(WEBSITE_VISIT_DELAY_MS);
754 }
755 log("SUCCESS", "ScrapeEmails", `Scraping done. Found emails for ${foundLeads.length} leads.`);
756 return { mandateId, correlationId: taskId, payload: { leads: foundLeads } };
757}
810 } catch (error: any) {
811 log("ERROR", "DraftEmails", `Failed for ${lead.name}: ${error.message}`, error);
812 finalLeads.push({ ...lead, draftedEmail: "[OpenAI API call failed]" });
813 }
814 await delay(300); // Small delay between OpenAI calls
1117<body><h1>Superpowered Agent Platform - Lead Gen Demo</h1>
1118<p>Runs <code>leadGenWorkflowV1</code>. See <a href="/">Original V3 Demo</a>.</p>
1119<p><strong>Note:</strong> Google Search is simulated. Scraping is basic.</p>
1120<form id="leadGenForm">
1121 <label for="searchQuery">Search Query (Required):</label><input type="text" id="searchQuery" name="searchQuery" required value="dentists in Los Angeles">

TESTmain.tsx4 matches

@vawogbemi•Updated 3 days ago
61 const fetchStories = async () => {
62 try {
63 const response = await fetch("/api/stories");
64 if (!response.ok) throw new Error("Failed to fetch dates");
65 const data = await response.json();
75 try {
76 dispatch({ type: "loading", value: true });
77 const response = await fetch(`/api/comments?query=${encodeURIComponent(query)}&story=${story}&page=${page}`);
78 if (!response.ok) throw new Error("Failed to fetch comments");
79 const data = await response.json();
364export default async function(req: Request): Promise<Response> {
365 const url = new URL(req.url);
366 if (url.pathname === "/api/stories") {
367 const storySearch = await hnSearch({
368 search_by_date: true,
385 }
386
387 if (url.pathname === "/api/comments") {
388 const params = url.searchParams;
389 const query = params.get("query") || "";

Afolabis2main.tsx8 matches

@vawogbemi•Updated 3 days ago
440
441function ProductCarousel({ children }: { children: React.ReactNode }) {
442 const [emblaRef, emblaApi] = useEmblaCarousel({
443 axis: "x",
444 loop: false,
465
466 useEffect(() => {
467 if (emblaApi) {
468 scrollByRef.current = (delta: number) => {
469 isScrollingRef.current = true;
470 const scrollResult = emblaApi.scrollTo(emblaApi.selectedScrollSnap() + Math.sign(delta));
471
472 if (scrollResult && typeof scrollResult.then === "function") {
479 };
480
481 const rootNode = emblaApi.rootNode();
482 rootNode.addEventListener("wheel", onWheel, { passive: false });
483 rootNode.style.overflowY = "auto";
488 };
489 }
490 }, [emblaApi, onWheel]);
491
492 return (
690
691 const script = document.createElement("script");
692 script.src = `https://maps.googleapis.com/maps/api/js?key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U&libraries=places`;
693 script.async = true;
694 script.defer = true;
814 // Reverse geocode the coordinates to get an address
815 const response = await fetch(
816 `https://maps.googleapis.com/maps/api/geocode/json?latlng=${position.coords.latitude},${position.coords.longitude}&key=AIzaSyAOtUMb5jLTjTVM7iKzIx2SJ3HgMKNcM7U`,
817 );
818 const data = await response.json();
1184});
1185
1186app.post("/api", async (c) => {
1187 console.log(c.req.body);
1188 return c.json({ ok: true });

stevensDemoREADME.md1 match

@kuanche•Updated 3 days ago
53You'll need to set up some environment variables to make it run.
54
55- `ANTHROPIC_API_KEY` for LLM calls
56- You'll need to follow [these instructions](https://docs.val.town/integrations/telegram/) to make a telegram bot, and set `TELEGRAM_TOKEN`. You'll also need to get a `TELEGRAM_CHAT_ID` in order to have the bot remember chat contents.
57- For the Google Calendar integration you'll need `GOOGLE_CALENDAR_ACCOUNT_ID` and `GOOGLE_CALENDAR_CALENDAR_ID`. See [these instuctions](https://www.val.town/v/stevekrouse/pipedream) for details.

reactHonoStarterindex.ts2 matches

@deboneil07•Updated 4 days ago
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error

linearStandupmain.tsx9 matches

@DJTILLU•Updated 4 days ago
57
58export async function exec(interval: Interval) {
59 const apiKey = Deno.env.get("LINEAR_API_KEY");
60 if (!apiKey) {
61 console.error("LINEAR_API_KEY not found in environment variables");
62 Deno.exit(1);
63 }
65 const { startDate, endDate } = getYesterdayDateRange();
66
67 const response = await fetch("https://api.linear.app/graphql", {
68 method: "POST",
69 headers: {
70 "Content-Type": "application/json",
71 Authorization: apiKey,
72 },
73 body: JSON.stringify({
80
81 if (data.errors) {
82 console.error("Error fetching data from Linear API:", data.errors);
83 Deno.exit(1);
84 }
94 }
95
96 const historyResponse = await fetch("https://api.linear.app/graphql", {
97 method: "POST",
98 headers: {
99 "Content-Type": "application/json",
100 Authorization: apiKey,
101 },
102 body: JSON.stringify({
190 }
191
192 const slackResponse = await fetch("https://slack.com/api/chat.postMessage", {
193 method: "POST",
194 headers: {

little-placemain.tsx9 matches

@openparens•Updated 4 days ago
81 async function fetchAndUpdateCanvas() {
82 try {
83 const response = await fetch("/api/canvas-state");
84 if (!response.ok) {
85 const errorText = await response.text().catch(() => "Unknown server error (canvas-state)");
92 drawCanvas(data.state);
93 } else {
94 console.error("Invalid data received from /api/canvas-state:", data);
95 drawCanvas([]); // Draw empty if data is not as expected
96 }
120
121 try {
122 const toggleResponse = await fetch("/api/toggle-square", {
123 method: "POST",
124 headers: {
146 const data = await toggleResponse.json();
147 if (data && data.state) {
148 // API returns the new state, use it directly.
149 drawCanvas(data.state);
150 } else {
151 console.error("Invalid data received from /api/toggle-square:", data);
152 // Fallback to full refresh if data from toggle is not as expected.
153 await fetchAndUpdateCanvas();
181 const url = new URL(req.url);
182
183 // API endpoint to get the current state of all filled squares
184 if (url.pathname === "/api/canvas-state" && req.method === "GET") {
185 try {
186 const filledSquares = await getCanvasState();
197 }
198
199 // API endpoint to toggle the state of a square
200 if (url.pathname === "/api/toggle-square" && req.method === "POST") {
201 try {
202 const { x, y } = await req.json();

buildindex.ts2 matches

@charmaine•Updated 4 days ago
7 <title>Val Town Hall Countdown</title>
8 <script src="https://cdn.twind.style" crossorigin></script>
9 <link rel="preconnect" href="https://fonts.googleapis.com">
10 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
11 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap" rel="stylesheet">
12 <script src="https://esm.town/v/std/catch"></script>
13 <style>

Townie-02index.ts3 matches

@jxnblk•Updated 4 days ago
36}));
37
38// token middleware for API requests
39app.all("/api/*", async (c, next) => {
40 const sessionCookie = getCookie(c, "_session");
41 if (!sessionCookie) {
47});
48
49app.route("/api", backend);
50
51app.get("/frontend/*", c => {

Townie-02useUser.tsx1 match

@jxnblk•Updated 4 days ago
1import { useState, useEffect } from "https://esm.sh/react@18.2.0?dev";
2
3const USER_ENDPOINT = "/api/user";
4
5export function useUser () {

vapi-minutes-db1 file match

@henrywilliams•Updated 1 day ago

vapi-minutes-db2 file matches

@henrywilliams•Updated 1 day ago
snartapi
papimark21