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/$%7Burl%7D?q=api&page=1388&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 17539 results for "api"(4859ms)

ghdbREADME.md3 matches

@begoon•Updated 8 months ago
3The key is a file path within a repository. The value is the file content.
4
5The val needs a GitHub token to access the GitHub API, the account name
6and the repository name.
7
8Also, the val needs GHDB_API_KEY variable. This value defines the exptected
9value of the GHDB_API_KEY header to allow access to the endpoints.
10
11Endpoints:

design32x32bitmapmain.tsx1 match

@chekos•Updated 8 months ago
461 <meta name="viewport" content="width=device-width, initial-scale=1.0">
462 <title>1-Bit Bitmap Editor</title>
463 <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet">
464 <style>${css}</style>
465 </head>

browserbasePuppeteerExamplemain.tsx1 match

@ryer•Updated 8 months ago
2
3const browser = await puppeteer.connect({
4 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
5});
6

blob_adminREADME.md1 match

@ianvph•Updated 8 months ago
9[![](https://stevekrouse-button.express.val.run/Install)](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
12
13# TODO

blob_adminREADME.md1 match

@aymeeko•Updated 8 months ago
9[![](https://stevekrouse-button.express.val.run/Install)](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
12
13# TODO

calculateTransitTimeValmain.tsx28 matches

@rochambeau314•Updated 8 months ago
1// This val calculates driving/transit time from given origins to the nearest grocery store, gym, FiDi, Roblox HQ, and Samsara in San Francisco.
2// It uses data from SF_Grocery and SF_Gyms blobs, and the Google Maps Directions API for travel times.
3// It also looks up the neighborhood based on the ZIP code using the SF_Neighborhood_ZIP blob.
4// Results are saved and displayed for each new address added, with options to delete individual results.
219 }
220
221 const apiKey = Deno.env.get("GOOGLE_MAPS_API_KEY");
222 if (!apiKey) {
223 console.error("API key is missing");
224 return new Response(JSON.stringify({ error: "API key is not configured" }), {
225 headers: { "Content-Type": "application/json" },
226 });
237
238 console.log("Finding nearest grocery");
239 const nearestGrocery = await findNearest(origin, groceries, apiKey);
240 console.log("Nearest grocery:", nearestGrocery);
241
242 console.log("Finding nearest gym");
243 const nearestGym = await findNearest(origin, gyms, apiKey);
244 console.log("Nearest gym:", nearestGym);
245
246 console.log("Calculating driving time to FiDi");
247 const fidiDestination = "548 Market St, San Francisco, CA 94104";
248 const fidiDrivingTime = await getDrivingTime(origin, fidiDestination, apiKey);
249 console.log("FiDi driving time:", fidiDrivingTime);
250
251 console.log("Calculating driving time to Roblox");
252 const robloxDestination = "910 Park Pl Ste 300, San Mateo, CA 94403";
253 const robloxDrivingTime = await getDrivingTime(origin, robloxDestination, apiKey, "09:00:00", "Tuesday");
254 console.log("Roblox driving time:", robloxDrivingTime);
255
256 console.log("Calculating transit time to Samsara");
257 const samsaraDestination = "1 De Haro St, San Francisco, CA 94103";
258 const samsaraTransitTime = await getTransitTime(origin, samsaraDestination, apiKey);
259 console.log("Samsara transit time:", samsaraTransitTime);
260
261 console.log("Extracting ZIP code and looking up neighborhood");
262 const zipCode = await getZipCode(origin, apiKey);
263 const neighborhoodZipMap = await blob.getJSON("SF_Neighborhood_ZIP");
264 const neighborhood = neighborhoodZipMap[zipCode] || "Unknown";
315}
316
317async function findNearest(origin: string, locations: any[], apiKey: string): Promise<any> {
318 console.log(`Finding nearest location among ${locations.length} options`);
319 const batchSize = 25; // Google Maps API typically allows up to 25 destinations per request
320 let nearestLocation = null;
321 let shortestTime = Infinity;
324 const batch = locations.slice(i, i + batchSize);
325 const destinations = batch.map(location => `${location.gps.lat},${location.gps.lng}`).join("|");
326 const distanceMatrixUrl = `https://maps.googleapis.com/maps/api/distancematrix/json?origins=${
327 encodeURIComponent(origin)
328 }&destinations=${encodeURIComponent(destinations)}&mode=driving&key=${apiKey}`;
329
330 console.log(`Fetching from Distance Matrix API for batch ${i / batchSize + 1}`);
331 const response = await fetch(distanceMatrixUrl);
332 const data = await response.json();
333 console.log("Distance Matrix API response status:", data.status);
334
335 if (data.status !== "OK") {
336 console.error("Distance Matrix API failed:", data);
337 throw new Error(`Distance Matrix API failed. Status: ${data.status}`);
338 }
339
362 origin: string,
363 destination: string,
364 apiKey: string,
365 arrivalTime?: string,
366 arrivalDay?: string,
367): Promise<string> {
368 let directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${
369 encodeURIComponent(origin)
370 }&destination=${encodeURIComponent(destination)}&mode=driving&key=${apiKey}`;
371
372 if (arrivalTime && arrivalDay) {
388}
389
390async function getTransitTime(origin: string, destination: string, apiKey: string): Promise<string> {
391 const directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${
392 encodeURIComponent(origin)
393 }&destination=${encodeURIComponent(destination)}&mode=transit&key=${apiKey}`;
394
395 const directionsResponse = await fetch(directionsUrl);
405}
406
407async function getZipCode(address: string, apiKey: string): Promise<string> {
408 const geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${
409 encodeURIComponent(address)
410 }&key=${apiKey}`;
411 const response = await fetch(geocodeUrl);
412 const data = await response.json();

blob_adminREADME.md1 match

@sammeltassen•Updated 8 months ago
9[![](https://stevekrouse-button.express.val.run/Install)](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
12
13# TODO

free_open_routermain.tsx16 matches

@taras•Updated 8 months ago
1const COMPLETION = "/api/v1/chat/completions";
2const MODELS = "/api/v1/models";
3const supported_urls = [COMPLETION, MODELS];
4import { blob } from "https://esm.town/v/std/blob";
5
6const isValTown = Deno.env.get("VALTOWN_API_URL");
7// Define a common set of CORS headers
8const corsHeaders = {
148 }
149
150 // Define the API endpoints and their respective tokens
151 const apiEndpoints = [
152 {
153 url: "https://openrouter.ai/api/v1/models",
154 token: Deno.env.get("OPEN_ROUTER_API_KEY"),
155 },
156 {
157 url: "https://api.groq.com/openai/v1/models",
158 token: Deno.env.get("GROQ_API_KEY"),
159 },
160 ];
161
162 // Create fetch promises for each API endpoint
163 const fetchPromises = apiEndpoints.map(({ url, token }) =>
164 fetch(url, {
165 headers: {
262 }
263
264 let bearerToken = Deno.env.get("OPEN_ROUTER_API_KEY");
265
266 let body: string | ReadableStream<Uint8Array> | null = null;
277 provider = "groq";
278 model = model.replace("groq/", "");
279 bearerToken = Deno.env.get("GROQ_API_KEY");
280 }
281 // Check if model ends with ':free'
297
298 if (provider === "groq") {
299 url.host = "api.groq.com";
300 url.pathname = url.pathname.replace("/api/v1", "/openai/v1");
301 url.port = "443";
302 url.protocol = "https";
318 };
319
320 // Special handling for /api/v1/models
321 if (url.pathname == MODELS) {
322 return new Response(JSON.stringify({ object: "list", data: freeModels }), {

celinewaitlistmain.tsx1 match

@mbo•Updated 8 months ago
1/**
2 * This Val creates a simple API endpoint that saves an email address for notifications
3 * using Val Town's JSON storage. It handles POST requests to save the submitted email
4 * and returns a simple confirmation message.

wed18_09_2024main.tsx2 matches

@hideokun•Updated 8 months ago
9type Y = Ex<1 | 2 | 3 | "a" | "b" | "c", "a" | "c">;
10
11type T = Capitalize<"asdf">;
12
13type TT = Uncapitalize<"AAA">;
14
15//

RandomQuoteAPI

@Freelzy•Updated 18 hours ago

HAPI7 file matches

@dIgitalfulus•Updated 1 day ago
Kapil01
apiv1