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=261&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 15380 results for "api"(1140ms)

PathPulseindex.html1 match

@sach•Updated 1 week ago
6 <title>Career Strengths Quiz - Cameroon</title>
7 <link rel="stylesheet" href="styles.css">
8 <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
9 <script src="https://cdn.twind.style" crossorigin></script>
10</head>

JobChatAppindex.ts2 matches

@cipher•Updated 1 week ago
62
63// Mount routes
64app.route("/api/jobs", jobRoutes);
65app.route("/api/chat", chatRoutes);
66app.route("/", staticRoutes);
67

JobChatAppchat.ts7 matches

@cipher•Updated 1 week ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getChatMessages, createChatMessage } from "../database/queries.ts";
3import { ApiResponse, ChatMessage } from "../../shared/types.ts";
4
5const chat = new Hono();
10 const limit = c.req.query("limit") ? parseInt(c.req.query("limit") as string) : 50;
11 const messages = await getChatMessages(limit);
12 const response: ApiResponse<ChatMessage[]> = {
13 success: true,
14 data: messages,
17 } catch (error) {
18 console.error("Error fetching chat messages:", error);
19 const response: ApiResponse<null> = {
20 success: false,
21 error: "Failed to fetch chat messages",
32 // Validate required fields
33 if (!body.username || !body.message) {
34 const response: ApiResponse<null> = {
35 success: false,
36 error: "Username and message are required",
44
45 if (!username || !message) {
46 const response: ApiResponse<null> = {
47 success: false,
48 error: "Username and message cannot be empty",
58
59 const createdMessage = await createChatMessage(newMessage);
60 const response: ApiResponse<ChatMessage> = {
61 success: true,
62 data: createdMessage,
65 } catch (error) {
66 console.error("Error creating chat message:", error);
67 const response: ApiResponse<null> = {
68 success: false,
69 error: "Failed to create chat message",

JobChatAppjobs.ts6 matches

@cipher•Updated 1 week ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getAllJobPostings, createJobPosting } from "../database/queries.ts";
3import { ApiResponse, JobPosting } from "../../shared/types.ts";
4
5const jobs = new Hono();
9 try {
10 const jobPostings = await getAllJobPostings();
11 const response: ApiResponse<JobPosting[]> = {
12 success: true,
13 data: jobPostings,
16 } catch (error) {
17 console.error("Error fetching job postings:", error);
18 const response: ApiResponse<null> = {
19 success: false,
20 error: "Failed to fetch job postings",
33 for (const field of requiredFields) {
34 if (!body[field]) {
35 const response: ApiResponse<null> = {
36 success: false,
37 error: `Missing required field: ${field}`,
52
53 const createdJob = await createJobPosting(newJob);
54 const response: ApiResponse<JobPosting> = {
55 success: true,
56 data: createdJob,
59 } catch (error) {
60 console.error("Error creating job posting:", error);
61 const response: ApiResponse<null> = {
62 success: false,
63 error: "Failed to create job posting",

mcpval-town-api.ts9 matches

@dinavinter•Updated 1 week ago
8
9// Function to create a file in a project
10export async function createProjectFile(projectId: string, path: string, content: string, apiKey: string) {
11 const response = await fetch(`https://api.val.town/v1/projects/${projectId}/files`, {
12 method: "POST",
13 headers: {
14 "Content-Type": "application/json",
15 Authorization: `Bearer ${apiKey}`,
16 },
17 body: JSON.stringify({
30
31// Function to update a file in a project
32export async function updateProjectFile(projectId: string, path: string, content: string, apiKey: string) {
33 const response = await fetch(`https://api.val.town/v1/projects/${projectId}/files/${path}`, {
34 method: "PUT",
35 headers: {
36 "Content-Type": "application/json",
37 Authorization: `Bearer ${apiKey}`,
38 },
39 body: JSON.stringify({
51
52// Function to set a file as HTTP handler
53export async function setFileAsHttpHandler(projectId: string, path: string, apiKey: string) {
54 const response = await fetch(`https://api.val.town/v1/projects/${projectId}/http-handler`, {
55 method: "PUT",
56 headers: {
57 "Content-Type": "application/json",
58 Authorization: `Bearer ${apiKey}`,
59 },
60 body: JSON.stringify({

kaloriindex.ts3 matches

@tempmail1•Updated 1 week ago
21});
22
23// API endpoint to analyze food image
24app.post("/api/analyze-food", async (c) => {
25 try {
26 console.log("Received analyze-food request");
45
46 // Call OpenAI to analyze the image
47 console.log("Calling OpenAI API...");
48 const openai = new OpenAI();
49 const response = await openai.chat.completions.create({

kaloriindex.html3 matches

@tempmail1•Updated 1 week ago
225 console.log('Sending image for analysis...');
226
227 // Send to API
228 const result = await fetch('/api/analyze-food', {
229 method: 'POST',
230 body: formData
232
233 if (!result.ok) {
234 throw new Error(`API request failed with status ${result.status}`);
235 }
236

kaloriREADME.md2 matches

@tempmail1•Updated 1 week ago
28
29Bu uygulama şunları kullanır:
30- OpenAI GPT-4o Vision API (yemek tanıma)
31- Web kamera API'si
32- Hono.js (backend framework)
33- TailwindCSS (styling)

stevensDemosendDailyBrief.ts8 matches

@mabkhan•Updated 1 week ago
97
98export async function sendDailyBriefing(chatId?: string, today?: DateTime) {
99 // Get API keys from environment
100 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
101 const telegramToken = Deno.env.get("TELEGRAM_TOKEN");
102
106 }
107
108 if (!apiKey) {
109 console.error("Anthropic API key is not configured.");
110 return;
111 }
122
123 // Initialize Anthropic client
124 const anthropic = new Anthropic({ apiKey });
125
126 // Initialize Telegram bot
162
163 // disabled title for now, it seemes unnecessary...
164 // await bot.api.sendMessage(chatId, `*${title}*`, { parse_mode: "Markdown" });
165
166 // Then send the main content
169
170 if (content.length <= MAX_LENGTH) {
171 await bot.api.sendMessage(chatId, content, { parse_mode: "Markdown" });
172 // Store the briefing in chat history
173 await storeChatMessage(
198 // Send each chunk as a separate message and store in chat history
199 for (const chunk of chunks) {
200 await bot.api.sendMessage(chatId, chunk, { parse_mode: "Markdown" });
201 // Store each chunk in chat history
202 await storeChatMessage(

stevensDemoREADME.md1 match

@mabkhan•Updated 1 week 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.

HN-fetch-call2 file matches

@ImGqb•Updated 1 day ago
fetch HackerNews by API

token-server1 file match

@kwhinnery_openai•Updated 3 days ago
Mint tokens to use with the OpenAI Realtime API for WebRTC
Kapil01
apiv1