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=fetch&page=1092&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=fetch

Returns an array of strings in format "username" or "username/projectName"

Found 13429 results for "fetch"(1879ms)

umapmain.tsx3 matches

@ejfox•Updated 9 months ago
142 <h3>Basic Example:</h3>
143 <pre>
144fetch("https://ejfox-umap.web.val.run/", {
145 method: "POST",
146 headers: { "Content-Type": "application/json" },
183const embeddings = await getEmbeddings(texts);
184
185fetch("/", {
186 method: "POST",
187 headers: { "Content-Type": "application/json" },
209 };
210
211 fetch("https://ejfox-umap.web.val.run", {
212 method: "POST",
213 headers: { "Content-Type": "application/json" },

zod_demo_frontendmain.tsx1 match

@stevekrouse•Updated 9 months ago
19
20 // Send data to server
21 const response = await fetch("/register", {
22 method: "POST",
23 headers: { "Content-Type": "application/json" },

blob_adminmain.tsx2 matches

@lithrel•Updated 9 months ago
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
137});
138
139export default modifyFetchHandler(passwordAuth(app.fetch));

weatherGPTmain.tsx1 match

@sarfrazkhan18•Updated 9 months ago
4let location = "brooklyn ny";
5let lang = "en";
6const weather = await fetch(
7 `https://wttr.in/${location}?lang=${lang}&format=j1`,
8).then(r => r.json());

umbrellaRemindermain.tsx2 matches

@sarfrazkhan18•Updated 9 months ago
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
4import { weatherGovGrid } from "https://esm.town/v/stevekrouse/weatherGovGrid";
14 lon,
15 });
16 let { properties: { periods } } = await fetchJSON(
17 grid.forecastHourly,
18 );

turnitdownmain.tsx1 match

@yawnxyz•Updated 9 months ago
83
84export default async function server(req: Request): Promise<Response> {
85 return app.fetch(req);
86}

iconExplorermain.tsx5 matches

@all•Updated 9 months ago
2 * This val creates an enhanced NPM package explorer using the npm registry API.
3 * It displays a grid of npm packages with basic information, categories, and navigation.
4 * The approach uses React for the frontend and fetch for API calls.
5 * It includes a details view for each package, a link to the npm page, and category navigation.
6 */
20
21 useEffect(() => {
22 fetchPackages();
23 }, [searchTerm, category, page]);
24
25 const fetchPackages = () => {
26 let url = `/search?q=${encodeURIComponent(searchTerm)}&size=${ITEMS_PER_PAGE}&from=${(page - 1) * ITEMS_PER_PAGE}`;
27 if (category !== "all") {
28 url += `&category=${encodeURIComponent(category)}`;
29 }
30 fetch(url)
31 .then(response => response.json())
32 .then(data => setPackages(data.objects));
114 }
115
116 const response = await fetch(apiUrl);
117 const data = await response.json();
118 return new Response(JSON.stringify(data), {

todaystatsmain.tsx45 matches

@ejfox•Updated 9 months ago
1/**
2 * This tool fetches real-time data from various free APIs to create a JSON object
3 * representing the current state of the world from different perspectives.
4 * Data is cached for 30 minutes using Val Town's SQLite database to reduce API calls and improve performance.
21}
22
23// Utility function for fetching JSON data
24async function fetchJSON(url: string) {
25 try {
26 const response = await fetch(url);
27 if (!response.ok) {
28 throw new Error(`HTTP error! status: ${response.status}`);
30 return await response.json();
31 } catch (error) {
32 console.error(`Error fetching ${url}:`, error);
33 return null;
34 }
40}
41
42// Utility function for fetching Wolfram Alpha data
43async function fetchWolframData(query: string) {
44 const appId = 'K8UTGR-8Y5G3A3VTP';
45 const url = `http://api.wolframalpha.com/v1/result?appid=${appId}&i=${encodeURIComponent(query)}`;
46 try {
47 const response = await fetch(url);
48 if (!response.ok) {
49 throw new Error(`HTTP error! status: ${response.status}`);
51 return await response.text();
52 } catch (error) {
53 console.error(`Error fetching Wolfram data for query "${query}":`, error);
54 return null;
55 }
56}
57
58// Utility function for fetching Alpha Vantage stock data
59async function fetchStockData(symbol: string) {
60 const apiKey = 'TD7I78XY3N2AGKWP';
61 const url = `https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=${symbol}&interval=5min&apikey=${apiKey}`;
62 try {
63 const data = await fetchJSON(url);
64 if (data && data['Time Series (5min)']) {
65 const latestTimestamp = Object.keys(data['Time Series (5min)'])[0];
70 }
71 } catch (error) {
72 console.error(`Error fetching stock data for symbol ${symbol}:`, error);
73 return null;
74 }
90 }
91
92 // If no valid cache, fetch new data
93 const issData = await fetchJSON('http://api.open-notify.org/iss-now.json');
94 const weatherData = await fetchJSON('https://api.open-meteo.com/v1/forecast?latitude=40.71&longitude=-74.01&current_weather=true&temperature_unit=celsius&daily=temperature_2m_max,temperature_2m_min,sunrise,sunset&timezone=America%2FNew_York');
95 const airQualityData = await fetchJSON('https://api.waqi.info/feed/geo:40.71;-74.01/?token=demo');
96 const cryptoData = await fetchJSON('https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,dogecoin,ripple,cardano,polkadot,litecoin&vs_currencies=usd');
97 const peopleInSpaceData = await fetchJSON('http://api.open-notify.org/astros.json');
98 const timeData = await fetchJSON('https://worldtimeapi.org/api/timezone/America/New_York,Europe/London,Asia/Tokyo');
99 const exchangeRateData = await fetchJSON('https://api.exchangerate-api.com/v4/latest/USD');
100 const usaCovidData = await fetchJSON('https://disease.sh/v3/covid-19/countries/USA');
101 const solarData = await fetchJSON('https://services.swpc.noaa.gov/json/solar-cycle/observed-solar-cycle-indices.json');
102 const earthquakeData = await fetchJSON('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson');
103
104 const worldPopulation = await fetchWolframData('current world population');
105 const carbonDioxide = await fetchWolframData('current atmospheric CO2');
106 const internetUsers = await fetchWolframData('number of internet users');
107 const globalTemperature = await fetchWolframData('current global average temperature');
108 const moonPhase = await fetchWolframData('current moon phase');
109 const usUnemploymentRate = await fetchWolframData('current US unemployment rate');
110 const globalInflationRate = await fetchWolframData('current global inflation rate');
111 const oilPrice = await fetchWolframData('current oil price');
112 const goldPrice = await fetchWolframData('current gold price');
113
114 const sp500 = await fetchStockData('SPY');
115 const dowJones = await fetchStockData('DIA');
116 const nasdaq = await fetchStockData('QQQ');
117 const appleStock = await fetchStockData('AAPL');
118 const nvidiaStock = await fetchStockData('NVDA');
119 const teslaStock = await fetchStockData('TSLA');
120 const amazonStock = await fetchStockData('AMZN');
121 const googleStock = await fetchStockData('GOOGL');
122
123 const worldState = {
267 </div>
268 <script>
269 async function fetchData() {
270 try {
271 const response = await fetch(window.location.href);
272 const data = await response.json();
273 document.getElementById('data').textContent = JSON.stringify(data, null, 2);
274 } catch (error) {
275 console.error('Error:', error);
276 document.getElementById('data').textContent = 'Error fetching data';
277 }
278 }
279 fetchData();
280 </script>
281</body>

daisyui_honomain.tsx1 match

@lnncoco•Updated 9 months ago
39});
40
41export default app.fetch;

nasamain.tsx20 matches

@ejfox•Updated 9 months ago
1/**
2 * This program creates an HTTP server that fetches various data from NASA APIs
3 * and returns a JSON response with a collection of interesting information about today.
4 * It uses multiple NASA APIs to gather diverse space-related data, including real-time imagery
10const NASA_API_KEY = 'vYg1cCNLVbcgNemMWuLEjoJsGOGbBXZjZjmwVwuV';
11
12async function fetchNASAData() {
13 const today = new Date().toISOString().split('T')[0];
14
15 // Fetch Astronomy Picture of the Day
16 const apodResponse = await fetch(`https://api.nasa.gov/planetary/apod?api_key=${NASA_API_KEY}`);
17 const apodData = await apodResponse.json();
18
19 // Fetch latest EPIC image metadata
20 const epicResponse = await fetch(`https://api.nasa.gov/EPIC/api/natural?api_key=${NASA_API_KEY}`);
21 const epicData = await epicResponse.json();
22 const latestEpicImage = epicData[0];
23
24 // Fetch Near Earth Objects for today
25 const neowsResponse = await fetch(`https://api.nasa.gov/neo/rest/v1/feed?start_date=${today}&end_date=${today}&api_key=${NASA_API_KEY}`);
26 const neowsData = await neowsResponse.json();
27
28 // Fetch Mars Weather data (note: this data is not always up-to-date)
29 const marsWeatherResponse = await fetch(`https://api.nasa.gov/insight_weather/?api_key=${NASA_API_KEY}&feedtype=json&ver=1.0`);
30 const marsWeatherData = await marsWeatherResponse.json();
31
32 // Fetch Earth Observatory Natural Event Tracker (EONET) data
33 const eonetResponse = await fetch(`https://eonet.gsfc.nasa.gov/api/v3/events`);
34 const eonetData = await eonetResponse.json();
35
36 // Fetch ISS Current Location
37 const issResponse = await fetch('http://api.open-notify.org/iss-now.json');
38 const issData = await issResponse.json();
39
40 // Fetch NASA Image and Video Library data
41 const nasaLibraryResponse = await fetch(`https://images-api.nasa.gov/search?q=space&media_type=image`);
42 const nasaLibraryData = await nasaLibraryResponse.json();
43
44 // Fetch TLE (Two-Line Element) data for satellites
45 const tleResponse = await fetch('https://www.celestrak.com/NORAD/elements/gp.php?GROUP=active&FORMAT=json');
46 const tleData = await tleResponse.json();
47
105export default async function server(request: Request): Promise<Response> {
106 try {
107 const nasaData = await fetchNASAData();
108 return new Response(JSON.stringify(nasaData, null, 2), {
109 headers: { 'Content-Type': 'application/json' },
110 });
111 } catch (error) {
112 return new Response(JSON.stringify({ error: 'Failed to fetch NASA data' }), {
113 status: 500,
114 headers: { 'Content-Type': 'application/json' },

GithubPRFetcher

@andybak•Updated 2 days ago

proxiedfetch1 file match

@jayden•Updated 2 days ago