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=170&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 14362 results for "api"(936ms)

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

tosMainLayout.tsx2 matches

@JoeEdoh•Updated 1 week ago
21 if (!token) return;
22
23 const response = await fetch("/api/chat/unread", {
24 headers: {
25 "Authorization": `Bearer ${token}`
54
55 // Just hit any authenticated endpoint to update online status
56 await fetch("/api/users/online", {
57 headers: {
58 "Authorization": `Bearer ${token}`

tosAuthPage.tsx2 matches

@JoeEdoh•Updated 1 week ago
23 // Login request
24 const loginData: LoginRequest = { email, password };
25 const response = await fetch("/api/auth/login", {
26 method: "POST",
27 headers: { "Content-Type": "application/json" },
40 // Signup request
41 const signupData: SignupRequest = { email, username, password };
42 const response = await fetch("/api/auth/signup", {
43 method: "POST",
44 headers: { "Content-Type": "application/json" },

tosindex.ts5 matches

@JoeEdoh•Updated 1 week ago
65});
66
67// API routes
68app.route("/api/auth", authRouter);
69app.route("/api/users", usersRouter.use(jwtMiddleware));
70app.route("/api/posts", postsRouter.use(jwtMiddleware));
71app.route("/api/chat", chatRouter.use(jwtMiddleware));
72
73// Static routes (must be last)

toschat.ts30 matches

@JoeEdoh•Updated 1 week ago
11 getUnreadMessageCounts
12} from "../database/queries.ts";
13import { ApiResponse, ChatRoom, ChatRoomMessage, Message, User } from "../../shared/types.ts";
14
15export const chatRouter = new Hono();
20 const chatRooms = await getChatRooms();
21
22 return c.json<ApiResponse<{ chatRooms: ChatRoom[] }>>({
23 success: true,
24 data: {
28 } catch (error) {
29 console.error("Get chat rooms error:", error);
30 return c.json<ApiResponse<null>>({
31 success: false,
32 error: "Internal server error"
43
44 if (isNaN(chatRoomId)) {
45 return c.json<ApiResponse<null>>({
46 success: false,
47 error: "Invalid chat room ID"
52
53 if (!success) {
54 return c.json<ApiResponse<null>>({
55 success: false,
56 error: "Failed to join chat room"
58 }
59
60 return c.json<ApiResponse<{ success: boolean }>>({
61 success: true,
62 data: {
66 } catch (error) {
67 console.error("Join chat room error:", error);
68 return c.json<ApiResponse<null>>({
69 success: false,
70 error: "Internal server error"
81
82 if (isNaN(chatRoomId)) {
83 return c.json<ApiResponse<null>>({
84 success: false,
85 error: "Invalid chat room ID"
90
91 if (!success) {
92 return c.json<ApiResponse<null>>({
93 success: false,
94 error: "Failed to leave chat room"
96 }
97
98 return c.json<ApiResponse<{ success: boolean }>>({
99 success: true,
100 data: {
104 } catch (error) {
105 console.error("Leave chat room error:", error);
106 return c.json<ApiResponse<null>>({
107 success: false,
108 error: "Internal server error"
117
118 if (isNaN(chatRoomId)) {
119 return c.json<ApiResponse<null>>({
120 success: false,
121 error: "Invalid chat room ID"
125 const messages = await getChatRoomMessages(chatRoomId);
126
127 return c.json<ApiResponse<{ messages: ChatRoomMessage[] }>>({
128 success: true,
129 data: {
133 } catch (error) {
134 console.error("Get chat room messages error:", error);
135 return c.json<ApiResponse<null>>({
136 success: false,
137 error: "Internal server error"
146
147 if (isNaN(chatRoomId)) {
148 return c.json<ApiResponse<null>>({
149 success: false,
150 error: "Invalid chat room ID"
154 const members = await getChatRoomMembers(chatRoomId);
155
156 return c.json<ApiResponse<{ members: User[] }>>({
157 success: true,
158 data: {
162 } catch (error) {
163 console.error("Get chat room members error:", error);
164 return c.json<ApiResponse<null>>({
165 success: false,
166 error: "Internal server error"
180
181 if (isNaN(receiverId)) {
182 return c.json<ApiResponse<null>>({
183 success: false,
184 error: "Invalid user ID"
187
188 if (!content || content.trim() === "") {
189 return c.json<ApiResponse<null>>({
190 success: false,
191 error: "Content is required"
196
197 if (!message) {
198 return c.json<ApiResponse<null>>({
199 success: false,
200 error: "Failed to send message"
202 }
203
204 return c.json<ApiResponse<{ message: Message }>>({
205 success: true,
206 data: {
210 } catch (error) {
211 console.error("Send direct message error:", error);
212 return c.json<ApiResponse<null>>({
213 success: false,
214 error: "Internal server error"
225
226 if (isNaN(otherUserId)) {
227 return c.json<ApiResponse<null>>({
228 success: false,
229 error: "Invalid user ID"
236 await markMessagesAsRead(userId, otherUserId);
237
238 return c.json<ApiResponse<{ messages: Message[] }>>({
239 success: true,
240 data: {
244 } catch (error) {
245 console.error("Get direct messages error:", error);
246 return c.json<ApiResponse<null>>({
247 success: false,
248 error: "Internal server error"
259
260 if (isNaN(otherUserId)) {
261 return c.json<ApiResponse<null>>({
262 success: false,
263 error: "Invalid user ID"
267 const success = await markMessagesAsRead(userId, otherUserId);
268
269 return c.json<ApiResponse<{ success: boolean }>>({
270 success: true,
271 data: {
275 } catch (error) {
276 console.error("Mark messages as read error:", error);
277 return c.json<ApiResponse<null>>({
278 success: false,
279 error: "Internal server error"
290 const unreadCounts = await getUnreadMessageCounts(userId);
291
292 return c.json<ApiResponse<{ unreadCounts: { [senderId: string]: number } }>>({
293 success: true,
294 data: {
298 } catch (error) {
299 console.error("Get unread message counts error:", error);
300 return c.json<ApiResponse<null>>({
301 success: false,
302 error: "Internal server error"

createemailapiv22 file matches

@souravvmishra•Updated 7 hours ago

waec_api6 file matches

@seyistry•Updated 13 hours ago
snartapi
mux
Your friendly, neighborhood video API.