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=176&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 14423 results for "api"(1300ms)

sa_pmtREADME.md1 match

@pro767•Updated 1 week ago
21
22- Frontend: HTML, JavaScript with Tailwind CSS for styling
23- Backend: TypeScript API using Hono framework and OpenAI integration
24- Deployed on Val Town
25

stockAppApp.tsx5 matches

@prashamtrivedi•Updated 1 week ago
12import QuickActions from "./QuickActions.tsx"
13import {User, CreateUserPayload} from "../../shared/types.ts"
14// import * as apiClient from "../apiClient.ts"; // This was removed
15
16const API_BASE_URL = "/api" // Ensure this is defined
17
18const App: FunctionComponent = () => {
52 try {
53 // Direct fetch for users
54 const response = await fetch(`/api/users`)
55 if (!response.ok) {
56 let errorData
60 errorData = {error: "Request failed", message: response.statusText || "Unknown error"}
61 }
62 console.error("API Error (fetchUsers):", errorData, "Status:", response.status)
63 throw new Error(errorData.message || errorData.error || `Failed to fetch users: ${response.status}`)
64 }
122 }
123 // Direct fetch to add user
124 const response = await fetch(`${API_BASE_URL}/users`, {
125 method: "POST",
126 headers: {

Launchingofproductindex.js6 matches

@Princessblessing93•Updated 1 week ago
144 sendButton.textContent = 'Sending...';
145
146 // Send message to API
147 const response = await fetch('/api/messages', {
148 method: 'POST',
149 headers: {
189async function fetchNewMessages() {
190 try {
191 const response = await fetch('/api/messages');
192 const result = await response.json();
193
336 submitButton.textContent = 'Posting...';
337
338 // Send job to API
339 const response = await fetch('/api/jobs', {
340 method: 'POST',
341 headers: {
432async function fetchJobs() {
433 try {
434 const response = await fetch('/api/jobs');
435 const result = await response.json();
436

Launchingofproductindex.ts27 matches

@Princessblessing93•Updated 1 week ago
10 addJobPosting
11} from "./database/queries.ts";
12import { ApiResponse, ChatMessage, JobPosting } from "../shared/types.ts";
13
14// Initialize the Hono app
52});
53
54// === Chat Message API Endpoints ===
55
56// API endpoint to get chat messages
57app.get("/api/messages", async c => {
58 try {
59 const messages = await getChatMessages();
60 const response: ApiResponse<ChatMessage[]> = {
61 success: true,
62 data: messages
65 } catch (error) {
66 console.error("Error fetching messages:", error);
67 const response: ApiResponse<null> = {
68 success: false,
69 error: "Failed to fetch messages"
73});
74
75// API endpoint to add a new chat message
76app.post("/api/messages", async c => {
77 try {
78 const body = await c.req.json();
81 // Validate input
82 if (!username || !message) {
83 const response: ApiResponse<null> = {
84 success: false,
85 error: "Username and message are required"
91 const newMessage = await addChatMessage(username, message);
92
93 const response: ApiResponse<ChatMessage> = {
94 success: true,
95 data: newMessage
98 } catch (error) {
99 console.error("Error adding message:", error);
100 const response: ApiResponse<null> = {
101 success: false,
102 error: "Failed to add message"
106});
107
108// === Job Posting API Endpoints ===
109
110// API endpoint to get all job postings
111app.get("/api/jobs", async c => {
112 try {
113 const jobs = await getJobPostings();
114 const response: ApiResponse<JobPosting[]> = {
115 success: true,
116 data: jobs
119 } catch (error) {
120 console.error("Error fetching job postings:", error);
121 const response: ApiResponse<null> = {
122 success: false,
123 error: "Failed to fetch job postings"
127});
128
129// API endpoint to get a single job posting
130app.get("/api/jobs/:id", async c => {
131 try {
132 const id = parseInt(c.req.param("id"));
133
134 if (isNaN(id)) {
135 const response: ApiResponse<null> = {
136 success: false,
137 error: "Invalid job ID"
143
144 if (!job) {
145 const response: ApiResponse<null> = {
146 success: false,
147 error: "Job posting not found"
150 }
151
152 const response: ApiResponse<JobPosting> = {
153 success: true,
154 data: job
157 } catch (error) {
158 console.error("Error fetching job posting:", error);
159 const response: ApiResponse<null> = {
160 success: false,
161 error: "Failed to fetch job posting"
165});
166
167// API endpoint to add a new job posting
168app.post("/api/jobs", async c => {
169 try {
170 const body = await c.req.json();
181 // Validate required fields
182 if (!title || !company || !description || !location || !contact_email || !posted_by) {
183 const response: ApiResponse<null> = {
184 success: false,
185 error: "Missing required fields"
199 );
200
201 const response: ApiResponse<JobPosting> = {
202 success: true,
203 data: newJob
206 } catch (error) {
207 console.error("Error adding job posting:", error);
208 const response: ApiResponse<null> = {
209 success: false,
210 error: "Failed to add job posting"

Launchingofproducttypes.ts1 match

@Princessblessing93•Updated 1 week ago
20}
21
22export interface ApiResponse<T> {
23 success: boolean;
24 data?: T;

YouthCareerToolkitindex.ts2 matches

@bolajeee•Updated 1 week ago
34});
35
36// API endpoint to generate content
37app.post("/api/generate", async (c) => {
38 try {
39 const data = await c.req.json() as GenerateRequest;

tosChatPage.tsx7 matches

@JoeEdoh•Updated 1 week ago
25 const fetchChatRooms = async () => {
26 try {
27 const response = await fetch("/api/chat/rooms", {
28 headers: {
29 "Authorization": `Bearer ${token}`
58 const fetchOnlineUsers = async () => {
59 try {
60 const response = await fetch("/api/users/online", {
61 headers: {
62 "Authorization": `Bearer ${token}`
89
90 try {
91 const response = await fetch(`/api/chat/rooms/${activeChatRoom.id}/messages`, {
92 headers: {
93 "Authorization": `Bearer ${token}`
101
102 // Join the chat room
103 await fetch(`/api/chat/rooms/${activeChatRoom.id}/join`, {
104 method: "POST",
105 headers: {
144
145 try {
146 const response = await fetch(`/api/chat/direct/${selectedUser.id}`, {
147 headers: {
148 "Authorization": `Bearer ${token}`
203
204 try {
205 const response = await fetch(`/api/chat/rooms/${activeChatRoom.id}/messages`, {
206 method: "POST",
207 headers: {
235
236 try {
237 const response = await fetch(`/api/chat/direct/${selectedUser.id}`, {
238 method: "POST",
239 headers: {

tosPostItem.tsx1 match

@JoeEdoh•Updated 1 week ago
45 try {
46 const token = localStorage.getItem("tos_token");
47 const response = await fetch(`/api/posts/${post.id}/comments`, {
48 headers: {
49 "Authorization": `Bearer ${token}`

tosFeedPage.tsx5 matches

@JoeEdoh•Updated 1 week ago
26 try {
27 const currentOffset = reset ? 0 : offset;
28 const response = await fetch(`/api/posts?limit=${limit}&offset=${currentOffset}`, {
29 headers: {
30 "Authorization": `Bearer ${token}`
74
75 try {
76 const response = await fetch("/api/posts", {
77 method: "POST",
78 headers: {
107 const handleLike = async (postId: number) => {
108 try {
109 const response = await fetch(`/api/posts/${postId}/like`, {
110 method: "POST",
111 headers: {
133 const handleComment = async (postId: number, content: string) => {
134 try {
135 const response = await fetch(`/api/posts/${postId}/comments`, {
136 method: "POST",
137 headers: {
166 const handleDelete = async (postId: number) => {
167 try {
168 const response = await fetch(`/api/posts/${postId}`, {
169 method: "DELETE",
170 headers: {

untitled-8850arena-blocks.html7 matches

@robertbrook•Updated 1 week ago
237
238 try {
239 // Log start of API request
240 console.log('🔄 Starting API request to Are.na...');
241 console.time('API Request');
242
243 // Fetch data from Are.na API
244 const response = await fetch('https://api.are.na/v2/search/blocks?sort=updated_at');
245
246 // Log response received
247 console.log(`✅ Response received with status: ${response.status}`);
248 console.timeEnd('API Request');
249
250 if (!response.ok) {
251 throw new Error(`API responded with status: ${response.status}`);
252 }
253

createemailapiv22 file matches

@souravvmishra•Updated 21 hours ago

waec_api6 file matches

@seyistry•Updated 1 day ago
snartapi
mux
Your friendly, neighborhood video API.