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/$2?q=api&page=13&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 15629 results for "api"(3156ms)

endpointsget_vals_endpoints.tsx11 matches

@chadparkerUpdated 17 hours ago
1export default async function(req: Request) {
2 try {
3 const apiKey = Deno.env.get("VALTOWN_API_TOKEN");
4
5 if (!apiKey) {
6 return new Response(
7 JSON.stringify({ error: "VALTOWN_API_TOKEN not found" }, null, 2),
8 { status: 400, headers: { "Content-Type": "application/json" } },
9 );
11
12 // Get my vals using the authenticated /me/vals endpoint
13 const valsResponse = await fetch("https://api.val.town/v2/me/vals", {
14 headers: {
15 "Authorization": `Bearer ${apiKey}`,
16 "Content-Type": "application/json",
17 },
20 if (!valsResponse.ok) {
21 const errorText = await valsResponse.text();
22 console.log("API Error response:", errorText);
23 throw new Error(
24 `Failed to fetch vals: ${valsResponse.status} ${valsResponse.statusText}. Response: ${errorText}`,
42 for (const val of vals) {
43 try {
44 // Use the files API to get the actual file structure
45 const filesResponse = await fetch(
46 `https://api.val.town/v2/vals/${val.id}/files?path=&recursive=true&limit=100`,
47 {
48 headers: {
49 "Authorization": `Bearer ${apiKey}`,
50 "Content-Type": "application/json",
51 },
80 // First get the file metadata to get the HTTP URL
81 const fileContentResponse = await fetch(
82 `https://api.val.town/v2/vals/${val.id}/files?path=${encodeURIComponent(endpointsFile.path)}`,
83 {
84 headers: {
85 "Authorization": `Bearer ${apiKey}`,
86 "Content-Type": "application/json",
87 },

HTTP_examplesREADME.md3 matches

@halloleoUpdated 18 hours ago
1# Val Town Docs - HTTP Examples
2
3HTTP triggers let you expose an API or website from your file.
4
5They are built on the web-standard
6[Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and
7[Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) objects,
8so are compatible with a number of web frameworks like
9[Hono](https://hono.dev/) and [Peko](https://github.com/sejori/peko).

umbrellaRemindermain.tsx1 match

@halloleoUpdated 18 hours ago
11 // Get weather data from Open-Meteo
12 const weatherUrl =
13 `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}&hourly=precipitation_probability&timezone=auto&forecast_days=1`;
14 const weatherResponse = await fetch(weatherUrl);
15 const weatherData = await weatherResponse.json();

untitled-4124index.html1 match

@digilocaltvUpdated 18 hours ago
6 <title>DigiLocalsTV News Channel</title>
7 <link rel="stylesheet" href="/style.css">
8 <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
9 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
10</head>

untitled-1267main.tsx30 matches

@Imrankhan2462Updated 20 hours ago
8 <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
9 <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
10 <script src="https://apis.google.com/js/api.js"></script>
11 <style>
12 @media print {
137 </div>
138 <script>
139 // Google Drive API कॉन्फ़िगरेशन
140 const CLIENT_ID = '706189550353-bbmvs2tklgqfm2jcanf0aqmrdm6ves5i.apps.googleusercontent.com';
141 const API_KEY = 'AIzaSyCPCjta_S_c4FYnnNKaRXWb6eaojXg4fqc';
142 const DISCOVERY_DOCS = ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'];
143 const SCOPES = 'https://www.googleapis.com/auth/drive.file';
144 let tokenClient;
145 let gapiInited = false;
146 let gisInited = false;
147
160 }
161
162 // Google API शुरू करें
163 function gapiLoaded() {
164 gapi.load('client', initializeGapiClient);
165 }
166
167 async function initializeGapiClient() {
168 try {
169 await gapi.client.init({
170 apiKey: API_KEY,
171 discoveryDocs: DISCOVERY_DOCS,
172 });
173 gapiInited = true;
174 maybeEnableButtons();
175 } catch (error) {
176 console.error('GAPI शुरू करने में त्रुटि:', error);
177 Swal.fire({
178 title: 'त्रुटि',
179 text: 'Google API शुरू करने में विफल। कृपया API_KEY और CLIENT_ID जाँचें।',
180 icon: 'error',
181 confirmButtonText: 'ठीक है'
196
197 function maybeEnableButtons() {
198 if (gapiInited && gisInited) {
199 document.getElementById('signInBtn').disabled = false;
200 }
218 };
219
220 if (gapi.client.getToken() === null) {
221 tokenClient.requestAccessToken({prompt: 'consent'});
222 } else {
353 // Google Drive पर एक्सेल फाइल अपलोड करें
354 async function uploadToGoogleDrive(newSale) {
355 if (!gapi.client.getToken()) {
356 Swal.fire({
357 title: 'त्रुटि',
398 let fileId;
399 try {
400 const searchResponse = await gapi.client.drive.files.list({
401 q: "name='zari_sales.xlsx' and trashed=false",
402 fields: 'files(id, name)'
432 if (fileId) {
433 // मौजूदा फाइल अपडेट करें
434 response = await fetch(`https://www.googleapis.com/upload/drive/v3/files/${fileId}?uploadType=multipart`, {
435 method: 'PATCH',
436 headers: new Headers({ 'Authorization': 'Bearer ' + gapi.client.getToken().access_token }),
437 body: form
438 });
439 } else {
440 // नई फाइल बनाएँ
441 response = await fetch('https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart', {
442 method: 'POST',
443 headers: new Headers({ 'Authorization': 'Bearer ' + gapi.client.getToken().access_token }),
444 body: form
445 });
792 document.getElementById('clearFilterBtn').addEventListener('click', clearFilters);
793
794 // Google API और Identity Services लोड करें
795 function loadGapiAndGis() {
796 const gapiScript = document.createElement('script');
797 gapiScript.src = 'https://apis.google.com/js/api.js';
798 gapiScript.onload = gapiLoaded;
799 document.body.appendChild(gapiScript);
800
801 const gisScript = document.createElement('script');
805 }
806
807 loadGapiAndGis();
808
809 // प्रारंभिक डिस्प्ले अपडेट

Testindex.ts2 matches

@wolfUpdated 20 hours ago
12app.get("/frontend/**/*", c => serveFile(c.req.path, import.meta.url));
13
14// Add your API routes here
15// app.get("/api/data", c => c.json({ hello: "world" }));
16
17// Unwrap and rethrow Hono errors as the original error

todo-apptypes.ts1 match

@pals_with_ValUpdated 20 hours ago
36}
37
38export interface ApiResponse<T = any> {
39 success: boolean;
40 data?: T;

todo-appTodoList.tsx1 match

@pals_with_ValUpdated 20 hours ago
179 <span className="text-sm text-gray-500">{getCategoryLabel(todo.category)}</span>
180 <span className="text-sm">{getPriorityIcon(todo.priority)}</span>
181 <span className="text-xs text-gray-500 capitalize">{todo.priority === 'high' ? 'Alta' : todo.priority === 'medium' ? 'Média' : 'Baixa'} prioridade</span>
182 {isOverdue(todo.dueDate) && !todo.completed && (
183 <span className="text-xs bg-red-100 text-red-700 px-2 py-1 rounded-full">

todo-appREADME.md6 matches

@pals_with_ValUpdated 20 hours ago
19```
20├── backend/
21│ ├── index.ts # Servidor Hono com API REST
22│ └── README.md
23├── frontend/
36```
37
38## 🚀 API Endpoints
39
40- `GET /` - Página inicial (landing page ou app)
41- `GET /api/todos` - Buscar tarefas do usuário
42- `POST /api/todos` - Criar nova tarefa
43- `PUT /api/todos/:id` - Atualizar tarefa
44- `DELETE /api/todos/:id` - Excluir tarefa
45
46## 🔧 Tecnologias

todo-appindex.ts20 matches

@pals_with_ValUpdated 20 hours ago
3import { blob } from "https://esm.town/v/std/blob";
4import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";
5import type { Todo, User, CreateTodoRequest, UpdateTodoRequest, ApiResponse } from "../shared/types.ts";
6
7const app = new Hono();
69});
70
71// API Routes
72
73// Get todos for authenticated user
74app.get("/api/todos", async (c) => {
75 const email = c.req.header("X-LastLogin-Email");
76
77 if (!email) {
78 return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
79 }
80
81 try {
82 const userData = await getUserData(email);
83 return c.json<ApiResponse<Todo[]>>({ success: true, data: userData.todos });
84 } catch (error) {
85 return c.json<ApiResponse>({ success: false, error: "Failed to fetch todos" }, 500);
86 }
87});
88
89// Create new todo
90app.post("/api/todos", async (c) => {
91 const email = c.req.header("X-LastLogin-Email");
92
93 if (!email) {
94 return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
95 }
96
114 await saveUserData(userData);
115
116 return c.json<ApiResponse<Todo>>({ success: true, data: newTodo });
117 } catch (error) {
118 return c.json<ApiResponse>({ success: false, error: "Failed to create todo" }, 500);
119 }
120});
121
122// Update todo
123app.put("/api/todos/:id", async (c) => {
124 const email = c.req.header("X-LastLogin-Email");
125 const todoId = c.req.param("id");
126
127 if (!email) {
128 return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
129 }
130
135 const todoIndex = userData.todos.findIndex(todo => todo.id === todoId);
136 if (todoIndex === -1) {
137 return c.json<ApiResponse>({ success: false, error: "Todo not found" }, 404);
138 }
139
148 await saveUserData(userData);
149
150 return c.json<ApiResponse<Todo>>({ success: true, data: updatedTodo });
151 } catch (error) {
152 return c.json<ApiResponse>({ success: false, error: "Failed to update todo" }, 500);
153 }
154});
155
156// Delete todo
157app.delete("/api/todos/:id", async (c) => {
158 const email = c.req.header("X-LastLogin-Email");
159 const todoId = c.req.param("id");
160
161 if (!email) {
162 return c.json<ApiResponse>({ success: false, error: "Not authenticated" }, 401);
163 }
164
168 const todoIndex = userData.todos.findIndex(todo => todo.id === todoId);
169 if (todoIndex === -1) {
170 return c.json<ApiResponse>({ success: false, error: "Todo not found" }, 404);
171 }
172
174 await saveUserData(userData);
175
176 return c.json<ApiResponse>({ success: true });
177 } catch (error) {
178 return c.json<ApiResponse>({ success: false, error: "Failed to delete todo" }, 500);
179 }
180});

googleGeminiAPI2 file matches

@michaelwschultzUpdated 5 hours ago

HN-fetch-call2 file matches

@ImGqbUpdated 3 days ago
fetch HackerNews by API
Kapil01
apiv1