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%22Image%20title%22?q=api&page=974&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 13269 results for "api"(2086ms)

resyGetMatchingSlotmain.tsx3 matches

@maxm•Updated 8 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { resyPublicAPIKey } from "https://esm.town/v/vtdocs/resyPublicAPIKey";
3
4export const resyGetMatchingSlot = async (
23 const endTime = new Date(`${day} ${end}`);
24 const slotsRes = await fetch(
25 `https://api.resy.com/4/find?lat=0&long=0&day=${day}&party_size=${partySize}&venue_id=${venueId}`,
26 {
27 "headers": {
28 "authorization":
29 `ResyAPI api_key="${resyPublicAPIKey}"`,
30 "x-resy-auth-token": token,
31 },

resyAuthmain.tsx3 matches

@vtdocs•Updated 8 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { resyPublicAPIKey } from "https://esm.town/v/vtdocs/resyPublicAPIKey";
3
4export const resyAuth = async (email: string, password: string): Promise<{
9 }[];
10}> => {
11 const authRes = await fetch("https://api.resy.com/3/auth/password", {
12 "headers": {
13 "authorization": `ResyAPI api_key="${resyPublicAPIKey}"`,
14 "content-type": "application/x-www-form-urlencoded",
15 "User-Agent":

resyAuthmain.tsx3 matches

@maxm•Updated 8 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2import { resyPublicAPIKey } from "https://esm.town/v/vtdocs/resyPublicAPIKey";
3
4export const resyAuth = async (email: string, password: string): Promise<{
9 }[];
10}> => {
11 const authRes = await fetch("https://api.resy.com/3/auth/password", {
12 "headers": {
13 "authorization": `ResyAPI api_key="${resyPublicAPIKey}"`,
14 "content-type": "application/x-www-form-urlencoded",
15 "User-Agent":

resyBotREADME.md1 match

@sec12tst8r84•Updated 8 months ago
9```ts
10const resyBotCron = async () => {
11 const bookingInfo = await api(@vtdocs.resyBot, {
12 slug: 'amaro-bar',
13 city: 'ldn',

frozenSapphireIguanamain.tsx24 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.
307 }
308
309 const apiKey = Deno.env.get("GOOGLE_MAPS_API_KEY");
310 if (!apiKey) {
311 console.error("API key is missing");
312 return new Response(JSON.stringify({ error: "API key is not configured" }), {
313 headers: { "Content-Type": "application/json" },
314 });
325
326 console.log("Finding nearest grocery");
327 const nearestGrocery = await findNearest(origin, groceries, apiKey);
328 console.log("Nearest grocery:", nearestGrocery);
329
330 console.log("Finding nearest gym");
331 const nearestGym = await findNearest(origin, gyms, apiKey);
332 console.log("Nearest gym:", nearestGym);
333
334 console.log("Calculating driving time to FiDi");
335 const fidiDestination = "548 Market St, San Francisco, CA 94104";
336 const fidiDrivingTime = await getDrivingTime(origin, fidiDestination, apiKey);
337 console.log("FiDi driving time:", fidiDrivingTime);
338
339 console.log("Calculating driving time to Roblox");
340 const robloxDestination = "910 Park Pl Ste 300, San Mateo, CA 94403";
341 const robloxDrivingTime = await getDrivingTime(origin, robloxDestination, apiKey, "09:00:00", "Tuesday");
342 console.log("Roblox driving time:", robloxDrivingTime);
343
344 console.log("Calculating transit time to Samsara");
345 const samsaraDestination = "1 De Haro St, San Francisco, CA 94103";
346 const samsaraTransitTime = await getTransitTime(origin, samsaraDestination, apiKey);
347 console.log("Samsara transit time:", samsaraTransitTime);
348
349 console.log("Extracting ZIP code and looking up neighborhood");
350 const zipCode = await getZipCode(origin, apiKey);
351 const neighborhoodZipMap = await blob.getJSON("SF_Neighborhood_ZIP");
352 const neighborhood = neighborhoodZipMap[zipCode] || "Unknown";
397}
398
399async function findNearest(origin: string, locations: any[], apiKey: string): Promise<any> {
400 console.log(`Finding nearest location among ${locations.length} options`);
401 const batchSize = 25; // Google Maps API typically allows up to 25 destinations per request
402 let nearestLocation = null;
403 let shortestTime = Infinity;
406 const batch = locations.slice(i, i + batchSize);
407 const destinations = batch.map(location => `${location.gps.lat},${location.gps.lng}`).join('|');
408 const distanceMatrixUrl = `https://maps.googleapis.com/maps/api/distancematrix/json?origins=${encodeURIComponent(origin)}&destinations=${encodeURIComponent(destinations)}&mode=driving&key=${apiKey}`;
409
410 console.log(`Fetching from Distance Matrix API for batch ${i / batchSize + 1}`);
411 const response = await fetch(distanceMatrixUrl);
412 const data = await response.json();
413 console.log("Distance Matrix API response status:", data.status);
414
415 if (data.status !== "OK") {
416 console.error("Distance Matrix API failed:", data);
417 throw new Error(`Distance Matrix API failed. Status: ${data.status}`);
418 }
419
439}
440
441async function getDrivingTime(origin: string, destination: string, apiKey: string, arrivalTime?: string, arrivalDay?: string): Promise<string> {
442 let directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${encodeURIComponent(origin)}&destination=${encodeURIComponent(destination)}&mode=driving&key=${apiKey}`;
443
444 if (arrivalTime && arrivalDay) {
460}
461
462async function getTransitTime(origin: string, destination: string, apiKey: string): Promise<string> {
463 const directionsUrl = `https://maps.googleapis.com/maps/api/directions/json?origin=${encodeURIComponent(origin)}&destination=${encodeURIComponent(destination)}&mode=transit&key=${apiKey}`;
464
465 const directionsResponse = await fetch(directionsUrl);
475}
476
477async function getZipCode(address: string, apiKey: string): Promise<string> {
478 const geocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${encodeURIComponent(address)}&key=${apiKey}`;
479 const response = await fetch(geocodeUrl);
480 const data = await response.json();

multipleBronzeCaterpillarmain.tsx1 match

@tbsvttr•Updated 8 months ago
11
12 await email({
13 subject: "New Vapi POST",
14 text: body,
15 });

notionGetDatabasemain.tsx2 matches

@junhoca•Updated 8 months ago
4 filter?: any;
5}) => {
6 const { Client, collectPaginatedAPI } = await import(
7 "https://deno.land/x/notion_sdk/src/mod.ts"
8 );
9 const notion = new Client({ auth });
10 return collectPaginatedAPI(notion.databases.query, {
11 database_id: databaseId,
12 filter,

add_to_notion_w_aiREADME.md1 match

@junhoca•Updated 8 months ago
14Supports: checkbox, date, multi_select, number, rich_text, select, status, title, url, email
15
16- Uses `NOTION_API_KEY`, `OPENAI_API_KEY` stored in env variables and uses [Valtown blob storage](https://esm.town/v/std/blob) to store information about the database.
17- Use `get_notion_db_info` to use the stored blob if exists or create one, use `get_and_save_notion_db_info` to create a new blob (and replace an existing one if exists).

add_to_notion_w_aimain.tsx3 matches

@junhoca•Updated 8 months ago
6import { z } from "npm:zod";
7
8const NOTION_API_KEY = process.env.NOTION_API_KEY;
9const notion = new Client({
10 auth: NOTION_API_KEY,
11});
12
27
28const oai = new OpenAI({
29 apiKey: process.env.OPENAI_API_KEY ?? undefined,
30});
31

chatWithCerebrasmain.tsx2 matches

@lazyplatypus•Updated 8 months ago
44
45 try {
46 const response = await fetch("/api/chat", {
47 method: "POST",
48 headers: { "Content-Type": "application/json" },
137
138async function server(request: Request): Promise<Response> {
139 if (request.method === "POST" && new URL(request.url).pathname === "/api/chat") {
140 const { messages, model } = await request.json();
141 const client = new Cerebras();

vapi-minutes-db1 file match

@henrywilliams•Updated 3 days ago

vapi-minutes-db2 file matches

@henrywilliams•Updated 3 days ago
mux
Your friendly, neighborhood video API.
api