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=19&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 11798 results for "api"(431ms)

myApi1 file match

@cmil•Updated 1 year ago

myApi1 file match

@red_dylan•Updated 1 year ago

myApi1 file match

@ccallaway93•Updated 1 year ago

myApi1 file match

@galligan•Updated 1 year ago

myApi1 file match

@bentz•Updated 1 year ago

myApi1 file match

@aatest•Updated 1 year ago

myApi1 file match

@jkell•Updated 1 year ago

myApi1 file match

@michael_town•Updated 1 year ago

myApi1 file match

@sbeben•Updated 1 year ago

myApi1 file match

@speepo•Updated 1 year ago

whatsapp-callbackindex.tsx20 matches

@yawnxyz•Updated 20 mins ago
8// Environment variables should be set in your Val Town val's settings
9const WHATSAPP_WEBHOOK_VERIFY_TOKEN = Deno.env.get("WHATSAPP_WEBHOOK_VERIFY_TOKEN");
10const WHATSAPP_GRAPH_API_TOKEN = Deno.env.get("WHATSAPP_GRAPH_API_TOKEN");
11const WHATSAPP_BUSINESS_ID = Deno.env.get("WHATSAPP_BUSINESS_ID");
12
42// --- Helper Functions ---
43async function sendWhatsAppMessage(phoneNumber, businessId, text, originalMessageId) {
44 if (!WHATSAPP_GRAPH_API_TOKEN || !businessId) {
45 console.error("WhatsApp API token or business ID is missing. Cannot send message.");
46 return;
47 }
54 method: "POST",
55 headers: {
56 "Authorization": `Bearer ${WHATSAPP_GRAPH_API_TOKEN}`,
57 "Content-Type": "application/json",
58 },
120 console.log(`[initiateChat] Sending to CF Orchestrator (${CLOUDFLARE_WORKER_ORCHESTRATOR_URL}/initiate-async-chat) for ${userIdentifier}:`, JSON.stringify(mcpPayload, null, 2));
121
122 const mcpApiResponse = await fetch(`${CLOUDFLARE_WORKER_ORCHESTRATOR_URL}/initiate-async-chat`, {
123 method: "POST",
124 headers: { "Content-Type": "application/json" },
126 });
127
128 if (!mcpApiResponse.ok) {
129 const errorText = await mcpApiResponse.text();
130 console.error(`[initiateChat] Error from CF Orchestrator for ${clientRequestId}: ${mcpApiResponse.status} ${mcpApiResponse.statusText}`, errorText);
131 await sendWhatsAppMessage(userIdentifier, businessPhoneNumberId, "Sorry, I couldn't start a session with the assistant.", originalMessageId);
132 return { error: true, details: errorText };
133 } else {
134 const mcpResponseData = await mcpApiResponse.json();
135 console.log(`[initiateChat] Response from CF Orchestrator for ${clientRequestId} (Status ${mcpApiResponse.status}):`, mcpResponseData);
136 return { error: false, data: mcpResponseData };
137 }
232 console.log(`[PROCESS] Initiating async for ${userPhoneNumber} (hash: ${queryHash || 'N/A'}).`);
233
234 if (WHATSAPP_GRAPH_API_TOKEN && business_phone_number_id) {
235 await initiateChatWithMCPOrchestrator(userQuery, userPhoneNumber, originalMessageId, business_phone_number_id);
236 try { // Mark as read
237 console.log(`Marking read for ${userPhoneNumber} (msg_id: ${originalMessageId})`);
238 const markReadResp = await fetch(`https://graph.facebook.com/v22.0/${business_phone_number_id}/messages`, {
239 method: "POST", headers: {"Authorization": `Bearer ${WHATSAPP_GRAPH_API_TOKEN}`, "Content-Type": "application/json"},
240 body: JSON.stringify({messaging_product: "whatsapp", status: "read", message_id: originalMessageId}),
241 });
244 } catch (e) { console.error(`Failed to mark read for ${userPhoneNumber}:`, e); }
245 } else {
246 console.error("WHATSAPP_GRAPH_API_TOKEN or business_phone_number_id missing.");
247 }
248 } else if (waMessage) {
281 // This means for direct GET, you'd need to monitor this Val's `/cf-worker-updates` or provide one.
282
283 const userIdentifier = "direct_api_user_" + crypto.randomUUID();
284 const clientRequestId = crypto.randomUUID(); // Not used by initiateChat directly, but good practice
285
400// Handle sending the welcome message
401app.post("/send-welcome", async (c) => {
402 if (!WHATSAPP_GRAPH_API_TOKEN || !WHATSAPP_BUSINESS_ID) {
403 console.error("WhatsApp API token or Business ID is not configured.");
404 return c.json({ error: "Server configuration error: WhatsApp API token or Business ID is missing." }, 500);
405 }
406
433 method: "POST",
434 headers: {
435 "Authorization": `Bearer ${WHATSAPP_GRAPH_API_TOKEN}`,
436 "Content-Type": "application/json",
437 },
444 );
445
446 const responseData = await response.json().catch(() => ({ error: { message: "Received non-JSON response from WhatsApp API" } }));
447
448 if (!response.ok) {
449 console.error(`Error sending custom message to ${phoneNumber}: ${response.status} ${response.statusText}`, responseData);
450 return c.json({ error: `WhatsApp API Error: ${responseData.error?.message || response.statusText}`, details: responseData }, response.status > 0 ? response.status : 500);
451 }
452

Flarum-Discussion-To-PlainTextapp.tsx2 matches

@tyler71•Updated 42 mins ago
124async function getDiscussionPosts(discussionId: string): Promise<PostT[]> {
125 // Used to get the list of post id's for the discussion.
126 const discussionRes = await fetch(`${server}/api/discussions/${discussionId}`);
127 const discussionResJson = await discussionRes.json();
128
136
137 await Promise.all(chunks.map(async (c: string[]) => {
138 const postRes = await fetch(`${server}/api/posts?filter[id]=${c.join(",")}`);
139 const postJson = await postRes.json();
140
apiv1
papimark21