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=29&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 20564 results for "api"(6177ms)

untitled-301README.md8 matches

@Mouhakโ€ขUpdated 3 days ago
17โ”‚ โ”‚ โ””โ”€โ”€ queries.ts # Database query functions
18โ”‚ โ”œโ”€โ”€ routes/
19โ”‚ โ”‚ โ”œโ”€โ”€ jobs.ts # Job posting API routes
20โ”‚ โ”‚ โ””โ”€โ”€ chat.ts # Chat API routes
21โ”‚ โ””โ”€โ”€ index.ts # Main Hono server
22โ”œโ”€โ”€ frontend/
32```
33
34## API Endpoints
35
36### Jobs
37- `GET /api/jobs` - Get all job postings
38- `POST /api/jobs` - Create a new job posting
39- `DELETE /api/jobs/:id` - Delete a job posting
40
41### Chat
42- `GET /api/chat/messages` - Get recent chat messages
43- `POST /api/chat/messages` - Send a new chat message
44
45## Database Schema

untitled-301jobs.ts11 matches

@Mouhakโ€ขUpdated 3 days ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getAllJobs, createJob, deleteJob } from "../database/queries.ts";
3import type { Job, ApiResponse } from "../../shared/types.ts";
4
5const jobs = new Hono();
9 try {
10 const jobList = await getAllJobs();
11 const response: ApiResponse<Job[]> = {
12 success: true,
13 data: jobList
15 return c.json(response);
16 } catch (error) {
17 const response: ApiResponse<Job[]> = {
18 success: false,
19 error: "Failed to fetch jobs"
31 if (!jobData.title || !jobData.company || !jobData.description ||
32 !jobData.location || !jobData.contact_email) {
33 const response: ApiResponse<Job> = {
34 success: false,
35 error: "Missing required fields"
41 const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
42 if (!emailRegex.test(jobData.contact_email)) {
43 const response: ApiResponse<Job> = {
44 success: false,
45 error: "Invalid email format"
49
50 const newJob = await createJob(jobData);
51 const response: ApiResponse<Job> = {
52 success: true,
53 data: newJob
55 return c.json(response, 201);
56 } catch (error) {
57 const response: ApiResponse<Job> = {
58 success: false,
59 error: "Failed to create job"
68 const id = parseInt(c.req.param("id"));
69 if (isNaN(id)) {
70 const response: ApiResponse<boolean> = {
71 success: false,
72 error: "Invalid job ID"
77 const deleted = await deleteJob(id);
78 if (!deleted) {
79 const response: ApiResponse<boolean> = {
80 success: false,
81 error: "Job not found"
84 }
85
86 const response: ApiResponse<boolean> = {
87 success: true,
88 data: true
90 return c.json(response);
91 } catch (error) {
92 const response: ApiResponse<boolean> = {
93 success: false,
94 error: "Failed to delete job"

untitled-301JobForm.tsx3 matches

@Mouhakโ€ขUpdated 3 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState } from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
3import type { Job, ApiResponse } from "../../shared/types.ts";
4
5interface JobFormProps {
25
26 try {
27 const response = await fetch('/api/jobs', {
28 method: 'POST',
29 headers: {
33 });
34
35 const result: ApiResponse<Job> = await response.json();
36
37 if (result.success && result.data) {

untitled-301JobBoard.tsx5 matches

@Mouhakโ€ขUpdated 3 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useEffect } from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
3import type { Job, ApiResponse } from "../../shared/types.ts";
4import JobForm from "./JobForm.tsx";
5
13 try {
14 setLoading(true);
15 const response = await fetch('/api/jobs');
16 const result: ApiResponse<Job[]> = await response.json();
17
18 if (result.success && result.data) {
40
41 try {
42 const response = await fetch(`/api/jobs/${jobId}`, {
43 method: 'DELETE'
44 });
45 const result: ApiResponse<boolean> = await response.json();
46
47 if (result.success) {

untitled-301index.ts3 matches

@Mouhakโ€ขUpdated 3 days ago
15await runMigrations();
16
17// API routes
18app.route("/api/jobs", jobsRouter);
19app.route("/api/chat", chatRouter);
20
21// Serve static files

untitled-301chat.ts9 matches

@Mouhakโ€ขUpdated 3 days ago
1import { Hono } from "https://esm.sh/hono@3.11.7";
2import { getRecentMessages, createMessage } from "../database/queries.ts";
3import type { ChatMessage, ApiResponse } from "../../shared/types.ts";
4
5const chat = new Hono();
9 try {
10 const messages = await getRecentMessages(50);
11 const response: ApiResponse<ChatMessage[]> = {
12 success: true,
13 data: messages
15 return c.json(response);
16 } catch (error) {
17 const response: ApiResponse<ChatMessage[]> = {
18 success: false,
19 error: "Failed to fetch messages"
30 // Basic validation
31 if (!messageData.username || !messageData.message) {
32 const response: ApiResponse<ChatMessage> = {
33 success: false,
34 error: "Username and message are required"
40 const trimmedMessage = messageData.message.trim();
41 if (trimmedMessage.length === 0) {
42 const response: ApiResponse<ChatMessage> = {
43 success: false,
44 error: "Message cannot be empty"
48
49 if (trimmedMessage.length > 500) {
50 const response: ApiResponse<ChatMessage> = {
51 success: false,
52 error: "Message too long (max 500 characters)"
58 const trimmedUsername = messageData.username.trim();
59 if (trimmedUsername.length === 0 || trimmedUsername.length > 50) {
60 const response: ApiResponse<ChatMessage> = {
61 success: false,
62 error: "Username must be 1-50 characters"
70 });
71
72 const response: ApiResponse<ChatMessage> = {
73 success: true,
74 data: newMessage
76 return c.json(response, 201);
77 } catch (error) {
78 const response: ApiResponse<ChatMessage> = {
79 success: false,
80 error: "Failed to send message"

untitled-301ChatRoom.tsx5 matches

@Mouhakโ€ขUpdated 3 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import React, { useState, useEffect, useRef } from "https://esm.sh/react@18.2.0?deps=react@18.2.0";
3import type { ChatMessage, ApiResponse } from "../../shared/types.ts";
4
5export default function ChatRoom() {
19 try {
20 setLoading(true);
21 const response = await fetch('/api/chat/messages');
22 const result: ApiResponse<ChatMessage[]> = await response.json();
23
24 if (result.success && result.data) {
46
47 try {
48 const response = await fetch('/api/chat/messages', {
49 method: 'POST',
50 headers: {
57 });
58
59 const result: ApiResponse<ChatMessage> = await response.json();
60
61 if (result.success && result.data) {

m5_simple_launcherlauncher_code.py2 matches

@dcm31โ€ขUpdated 3 days ago
35
36 import requests2
37 response = requests2.get(f"{CODE_SERVER}/api/apps")
38
39 if response.status_code == 200:
109
110 # Fetch code from server
111 url = f"{CODE_SERVER}/api/apps/{app_id}/code"
112 import requests2
113 response = requests2.get(url)

twitterNewTweetAlertmain.tsx11 matches

@axldefiโ€ขUpdated 3 days ago
2
3const discordWebhookUrl = Deno.env.get("DISCORD_WEBHOOK_URL");
4const telegramBotApiToken = Deno.env.get("TELEGRAM_API_TOKEN");
5const telegramUserId = Deno.env.get("TELEGRAM_USER_ID");
6
7if (!(discordWebhookUrl || (telegramBotApiToken && telegramUserId))) {
8 throw new Error("Either Discord webhook URL or Telegram bot API token and user ID must be provided.");
9}
10
94
95 try {
96 if (telegramBotApiToken && telegramUserId) {
97 await sendEventToTelegram(event);
98 }
190
191 if (!response.ok) {
192 throw new Error(`Discord API responded with status: ${response.status}`);
193 }
194}
227 message += `๐ŸŒ Language: ${tweet.lang.toUpperCase()}`;
228
229 const telegramApiUrl = `https://api.telegram.org/bot${telegramBotApiToken}/sendMessage`;
230
231 const payload = {
236 };
237
238 const response = await fetch(telegramApiUrl, {
239 method: "POST",
240 headers: {
246 if (!response.ok) {
247 const errorData = await response.json();
248 throw new Error(`Telegram API responded with status: ${response.status}, message: ${errorData.description}`);
249 }
250
262
263async function sendPhotoToTelegram(photoUrl: string): Promise<void> {
264 const telegramApiUrl = `https://api.telegram.org/bot${telegramBotApiToken}/sendPhoto`;
265
266 const payload = {
269 };
270
271 const response = await fetch(telegramApiUrl, {
272 method: "POST",
273 headers: {
279 if (!response.ok) {
280 const errorData = await response.json();
281 throw new Error(`Telegram API responded with status: ${response.status}, message: ${errorData.description}`);
282 }
283}

react-hono-with-react-routertasteAnalysis.tsx2 matches

@damonbโ€ขUpdated 3 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2import { capitalize, Tooltip } from '@mui/material';
3import chroma from 'chroma-js';
4import React, { ReactNode } from 'react';
68 : Tastes.map((taste) => (
69 <Dot key={taste} content={shortForm(taste)} color={color} intensity={tasteInstance[taste]} tooltip={<div>
70 <div>{capitalize(taste)}</div>
71 <div>Intensity: {tasteInstance[taste].toFixed(2)}/10</div>
72 </div>} />

claude-api1 file match

@ziyanwouldโ€ขUpdated 1 day ago

api-workshop

@danarddanielsjrโ€ขUpdated 2 days ago
codingpapi
replicate
Run AI with an API