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/?q=api&page=829&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 11605 results for "api"(1721ms)

whatsappWebhookExamplemain.tsx2 matches

@yawnxyz•Updated 8 months ago
2 * Simple, free webhook to start using WhatsApp Platform.
3 * Handles GET request for verification, and POST request for notifications.
4 * Meta example: https://glitch.com/edit/#!/whatsapp-cloud-api-echo-bot
5 *
6 * Setup:
9 * 2. Set your env variable `WHATSAPP_WEBHOOK_VERIFY_TOKEN`
10 * Set env variables in val: https://docs.val.town/reference/environment-variables/
11 * hub.verify_token value: https://developers.facebook.com/docs/graph-api/webhooks/getting-started
12 *
13 * Note:

todaystatsmain.tsx12 matches

@ejfox•Updated 8 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.
5 */
6
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);
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);
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');

nasamain.tsx10 matches

@ejfox•Updated 8 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
5 * and additional interesting data points.
6 */
8import { DOMParser } from "https://esm.sh/linkedom";
9
10const NASA_API_KEY = 'vYg1cCNLVbcgNemMWuLEjoJsGOGbBXZjZjmwVwuV';
11
12async function fetchNASAData() {
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

aqiREADME.md1 match

@mykalattinybox•Updated 8 months ago
4
51. Click `Fork`
62. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via [nominatim's geocoder API](https://www.val.town/v/stevekrouse/nominatimSearch).
73. Click `Run`
8

sqliteExplorerAppREADME.md1 match

@andrewn•Updated 8 months ago
13## Authentication
14
15Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
16
17## Todos / Plans

sqliteExplorerAppmain.tsx2 matches

@andrewn•Updated 8 months ago
27 <head>
28 <title>SQLite Explorer</title>
29 <link rel="preconnect" href="https://fonts.googleapis.com" />
30
31 <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32 <link
33 href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34 rel="stylesheet"
35 />

emailREADME.md1 match

@shouser•Updated 8 months ago
54You can attach files to your emails by using the `attachments` field.
55Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
56which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
57method is doing in this example:
58

emailmain.tsx2 matches

@shouser•Updated 8 months ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { parseSendGridEmail } from "https://esm.town/v/stevekrouse/parseSendGridEmail?v=8";
3import { parseSendGridEmails } from "https://esm.town/v/stevekrouse/parseSendGridEmails?v=10";
69}) => {
70 let result = await fetch(
71 `${API_URL}/v1/email`,
72 {
73 method: "POST",

reluctantCoffeeGayalmain.tsx9 matches

@kaz•Updated 8 months ago
49 const fetchAnswersAndRankings = async () => {
50 if (user) {
51 const response = await fetch("/api/answers");
52 const data = await response.json();
53 setAnswers(data.answers);
59 const saveAnswer = useCallback(async (newAnswer: Answer, losingAnswer: string) => {
60 if (user) {
61 await fetch("/api/answer", {
62 method: "POST",
63 headers: { "Content-Type": "application/json" },
70 const clearAnswers = useCallback(async () => {
71 if (user) {
72 await fetch("/api/clear-answers", { method: "POST" });
73 setAnswers([]);
74 setRankings([]);
242 const handleLogin = useCallback(async (e: React.FormEvent) => {
243 e.preventDefault();
244 const response = await fetch("/api/login", {
245 method: "POST",
246 headers: { "Content-Type": "application/json" },
314
315 const url = new URL(request.url);
316 if (url.pathname === "/api/login") {
317 const { username } = await request.json();
318 await sqlite.execute(`INSERT OR IGNORE INTO ${KEY}_users (username) VALUES (?)`, [username]);
321 }
322
323 if (url.pathname === "/api/answer") {
324 const { questionId, answer, losingAnswer } = await request.json();
325 const userId = 1; // In a real app, you'd get this from the session
333 }
334
335 if (url.pathname === "/api/answers") {
336 const userId = 1; // In a real app, you'd get this from the session
337 const answers = (await sqlite.execute(`SELECT * FROM ${KEY}_answers WHERE user_id = ?`, [userId])).rows;
340 }
341
342 if (url.pathname === "/api/clear-answers") {
343 const userId = 1; // In a real app, you'd get this from the session
344 await sqlite.execute(`DELETE FROM ${KEY}_answers WHERE user_id = ?`, [userId]);
411
412const css = `
413 @import url('https://fonts.googleapis.com/css2?family=Pacifico&family=Roboto:wght@300;400;500&display=swap');
414
415 :root {

fancyPlumSquirrelmain.tsx2 matches

@cofsana•Updated 8 months ago
1/**
2 * This val creates an elegant and professional web app for managing panel members for the State Street discussion.
3 * It uses React for the UI, SQLite for storing panel member information, and the Fetch API to communicate with the server.
4 * The design is clean and sophisticated, with a muted color palette and subtle animations.
5 */
182
183const css = `
184 @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Roboto:wght@300;400;700&display=swap');
185
186 :root {

new-val-api-21 file match

@shouser•Updated 14 hours ago
This is an example of using the API to create a val.

gptApiTemplate2 file matches

@charmaine•Updated 1 day ago
artivilla
founder @outapint.io vibe coding on val.town. dm me to build custom vals: https://artivilla.com
mux
Your friendly, neighborhood video API.