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=131&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 25377 results for "api"(5718ms)

hello-realtimeutils.ts8 matches

@dvergin•Updated 2 weeks ago
1const MODEL = "gpt-realtime";
2const INSTRUCTIONS = `
3 Greet the user in English, and thank them for trying the new OpenAI Realtime API.
4 Give them a brief summary based on the list below, and then ask if they have any questions.
5 Answer questions using the information below. For questions outside this scope,
7 ---
8 Short summary:
9 - The Realtime API is now generally available, and has improved instruction following, voice naturalness, and audio quality.
10 There are two new voices and it's easier to develop for. There's also a new telephony integration for phone scenarios.
11 Full list of improvements:
16 - higher audio quality
17 - improved handling of alphanumerics (eg, properly understanding credit card and phone numbers)
18 - support for the OpenAI Prompts API
19 - support for MCP-based tools
20 - auto-truncation to reduce context size
21 - native telephony support, making it simple to connect voice calls to existing Realtime API applications
22 - when using WebRTC, you can connect without needing an ephemeral token
23 - when using WebRTC, you can now control sessions (including tool calls) from the server
27const VOICE = "marin";
28
29const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
30if (!OPENAI_API_KEY) {
31 throw new Error("🔴 OpenAI API key not configured");
32}
33
34export function makeHeaders(contentType?: string) {
35 const obj: Record<string, string> = {
36 Authorization: `Bearer ${OPENAI_API_KEY}`,
37 };
38 if (contentType) obj["Content-Type"] = contentType;

hello-realtimesip.ts1 match

@dvergin•Updated 2 weeks ago
27
28 // Accept the call.
29 const url = `https://api.openai.com/v1/realtime/calls/${callId}/accept`;
30 const headers = makeHeaders("application/json");
31 const body = JSON.stringify(makeSession());

hello-realtimertc.ts1 match

@dvergin•Updated 2 weeks ago
7rtc.post("/", async (c) => {
8 // Create the call.
9 const url = "https://api.openai.com/v1/realtime/calls";
10 const headers = makeHeaders();
11 const fd = new FormData();

hello-realtimeREADME.md2 matches

@dvergin•Updated 2 weeks ago
4You can access the app via WebRTC at https://hello-realtime.val.run, or via SIP by calling 425-800-0042.
5
6This demo shows off the new SIP API, the new all-in-one WebRTC API, and the new server-side websocket interface.
7
8If you remix the app, you'll just need to pop in your own OPENAI_API_KEY (from platform.openai.com), and also the OPENAI_SIGNING_SECRET if you want to use the SIP interface.

hello-realtimeobserver.ts1 match

@dvergin•Updated 2 weeks ago
8observer.post("/:callId", async (c) => {
9 const callId = c.req.param("callId");
10 const url = `wss://api.openai.com/v1/realtime?call_id=${callId}`;
11 const ws = new WebSocket(url, { headers: makeHeaders() });
12 ws.on("open", () => {

hello-realtimeindex.html1 match

@dvergin•Updated 2 weeks ago
4 <meta charset="utf-8" />
5 <meta name="viewport" content="width=device-width, initial-scale=1" />
6 <title>OpenAI Realtime API Voice Agent</title>
7 <style>
8 :root {

ncaa-football-liveboardmain.tsx3 matches

@tldr•Updated 2 weeks ago
5// ===============================
6
7// [REPO-SWAP #1]: replace this stub with: import { logger } from "@api/shared/logger"
8const logger = {
9 child: (x?: any) => console,
13const log = logger.child?.({ label: "tool:topic:ncaaf-liveboard" }) || console;
14
15// [REPO-SWAP #2]: replace this local helper with: import { fromUnixTime } from "@api/shared/utils"
16function fromUnixTime(input?: number | string) {
17 let date: Date;
33// [REPO-SWAP #3]: in repo, use ESPN_ENDPOINTS.NCAAF_SCOREBOARD from your config
34const ESPN_SCOREBOARD =
35 "https://site.api.espn.com/apis/site/v2/sports/football/college-football/scoreboard";
36
37// ====== toggles ======

weekly-schedDelegationPage.tsx3 matches

@jeffroche•Updated 2 weeks ago
42 const fetchResponsibilities = async () => {
43 try {
44 const response = await fetch("/api/responsibilities");
45 const result = await response.json();
46 if (result.success) {
75
76 const response = await fetch(
77 `/api/tasks/week?start=${startDate}&end=${endDate}`,
78 );
79 const result = await response.json();
145
146 await fetch(
147 `/api/tasks/by-responsibility/${responsibilityId}%23${date}`,
148 {
149 method: "PUT",

weekly-schedREADME.md13 matches

@jeffroche•Updated 2 weeks ago
19
20### Backend
21- Hono API framework
22- SQLite database
23- RESTful API endpoints
24- SPA routing support
25
973. View and manage the schedule in the "Calendar" view
98
99## API Endpoints
100
101- `GET /api/responsibilities` - Get all active responsibilities
102- `POST /api/responsibilities` - Create new responsibility
103- `PUT /api/responsibilities/:id` - Update responsibility
104- `DELETE /api/responsibilities/:id` - Archive responsibility
105- `GET /api/tasks/week?start=YYYY-MM-DD&end=YYYY-MM-DD` - Get tasks for week
106- `POST /api/tasks` - Create new task assignment
107- `PUT /api/tasks/:id` - Update task (owner/notes)
108- `PUT /api/tasks/by-responsibility/{responsibilityId}#{date}` - Create or update task by responsibility and date (upsert)
109- `DELETE /api/tasks/:id` - Delete task assignment
110
111### Task Management
112
113The app now supports a unified PUT endpoint for creating or updating tasks:
114- **Endpoint**: `PUT /api/tasks/by-responsibility/{responsibilityId}#{date}`
115- **Format**: The ID is formatted as `{responsibilityId}#{date}` (e.g., `1#2024-01-15`)
116- **Behavior**: Creates a new task if it doesn't exist, updates if it does

weekly-schedtasks.ts35 matches

@jeffroche•Updated 2 weeks ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import type { ApiResponse, CreateTaskData, UpdateTaskData, UpsertTaskData } from "../../shared/types.ts";
3import {
4 getTasksForWeek,
13const app = new Hono();
14
15// GET /api/tasks/week?start=YYYY-MM-DD&end=YYYY-MM-DD - Get tasks for a week
16app.get("/week", async (c) => {
17 try {
20
21 if (!startDate || !endDate) {
22 return c.json({ success: false, error: "Start and end dates are required" } as ApiResponse<never>, 400);
23 }
24
25 const tasks = await getTasksForWeek(startDate, endDate);
26 return c.json({ success: true, data: tasks } as ApiResponse<typeof tasks>);
27 } catch (error) {
28 console.error("Error fetching tasks for week:", error);
29 return c.json({ success: false, error: "Failed to fetch tasks" } as ApiResponse<never>, 500);
30 }
31});
32
33// GET /api/tasks/:id - Get task by ID
34app.get("/:id", async (c) => {
35 try {
36 const id = parseInt(c.req.param("id"));
37 if (isNaN(id)) {
38 return c.json({ success: false, error: "Invalid task ID" } as ApiResponse<never>, 400);
39 }
40
41 const task = await getTaskById(id);
42 if (!task) {
43 return c.json({ success: false, error: "Task not found" } as ApiResponse<never>, 404);
44 }
45
46 return c.json({ success: true, data: task } as ApiResponse<typeof task>);
47 } catch (error) {
48 console.error("Error fetching task:", error);
49 return c.json({ success: false, error: "Failed to fetch task" } as ApiResponse<never>, 500);
50 }
51});
52
53// POST /api/tasks - Create new task
54app.post("/", async (c) => {
55 try {
58 // Validate required fields
59 if (!body.responsibilityId || !body.date || !body.owner) {
60 return c.json({ success: false, error: "ResponsibilityId, date, and owner are required" } as ApiResponse<never>, 400);
61 }
62
63 // Validate owner enum
64 if (!['Jeff', 'Tara'].includes(body.owner)) {
65 return c.json({ success: false, error: "Invalid owner value" } as ApiResponse<never>, 400);
66 }
67
69 const existingTask = await getTaskByResponsibilityAndDate(body.responsibilityId, body.date);
70 if (existingTask) {
71 return c.json({ success: false, error: "Task already exists for this responsibility and date" } as ApiResponse<never>, 409);
72 }
73
74 const task = await createTask(body);
75 return c.json({ success: true, data: task } as ApiResponse<typeof task>, 201);
76 } catch (error) {
77 console.error("Error creating task:", error);
78 return c.json({ success: false, error: "Failed to create task" } as ApiResponse<never>, 500);
79 }
80});
81
82// PUT /api/tasks/:id - Update task
83app.put("/:id", async (c) => {
84 try {
85 const id = parseInt(c.req.param("id"));
86 if (isNaN(id)) {
87 return c.json({ success: false, error: "Invalid task ID" } as ApiResponse<never>, 400);
88 }
89
92 // Validate owner enum if provided
93 if (body.owner && !['Jeff', 'Tara'].includes(body.owner)) {
94 return c.json({ success: false, error: "Invalid owner value" } as ApiResponse<never>, 400);
95 }
96
97 const task = await updateTask(id, body);
98 if (!task) {
99 return c.json({ success: false, error: "Task not found" } as ApiResponse<never>, 404);
100 }
101
102 return c.json({ success: true, data: task } as ApiResponse<typeof task>);
103 } catch (error) {
104 console.error("Error updating task:", error);
105 return c.json({ success: false, error: "Failed to update task" } as ApiResponse<never>, 500);
106 }
107});
108
109// PUT /api/tasks/by-responsibility/{responsibilityId}#{date} - Create or update task by responsibility and date
110app.put("/by-responsibility/:compositeId", async (c) => {
111 try {
117
118 if (parts.length !== 2) {
119 return c.json({ success: false, error: "Invalid task ID format. Use {responsibilityId}#{date}" } as ApiResponse<never>, 400);
120 }
121
124
125 if (isNaN(responsibilityId)) {
126 return c.json({ success: false, error: "Invalid responsibility ID" } as ApiResponse<never>, 400);
127 }
128
129 // Validate date format (YYYY-MM-DD)
130 if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
131 return c.json({ success: false, error: "Invalid date format. Use YYYY-MM-DD" } as ApiResponse<never>, 400);
132 }
133
136 // Validate required fields
137 if (!body.owner) {
138 return c.json({ success: false, error: "Owner is required" } as ApiResponse<never>, 400);
139 }
140
141 // Validate owner enum
142 if (!['Jeff', 'Tara'].includes(body.owner)) {
143 return c.json({ success: false, error: "Invalid owner value" } as ApiResponse<never>, 400);
144 }
145
149 });
150
151 return c.json({ success: true, data: task } as ApiResponse<typeof task>);
152 } catch (error) {
153 console.error("Error upserting task:", error);
154 return c.json({ success: false, error: "Failed to create or update task" } as ApiResponse<never>, 500);
155 }
156});
157
158// DELETE /api/tasks/:id - Delete task
159app.delete("/:id", async (c) => {
160 try {
161 const id = parseInt(c.req.param("id"));
162 if (isNaN(id)) {
163 return c.json({ success: false, error: "Invalid task ID" } as ApiResponse<never>, 400);
164 }
165
166 const success = await deleteTask(id);
167 if (!success) {
168 return c.json({ success: false, error: "Task not found" } as ApiResponse<never>, 404);
169 }
170
171 return c.json({ success: true } as ApiResponse<never>);
172 } catch (error) {
173 console.error("Error deleting task:", error);
174 return c.json({ success: false, error: "Failed to delete task" } as ApiResponse<never>, 500);
175 }
176});

todoist-api

@scottscharl•Updated 17 hours ago

elevenLabsDialogueTester2 file matches

@dcm31•Updated 1 day ago
Public tester for ElevenLabs text-to-dialogue API
fapian
<("<) <(")> (>")>
Kapil01