5export let aqiLocation = async ({ lat, lon }: { lat: number; lon: number }) => {
6 const { results } = fetchJSON(
7 "https://api.openaq.org/v2/locations?" +
8 new URLSearchParams({
9 limit: "10",
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3// accessible via API at https://api.val.town/eval/@stevekrouse.basicAPIEx
4export const basicAPIEx = fetchJSON(
5 "https://date.nager.at/api/v2/publicholidays/2023/US"
6);
7// Bonus: the whole runtime is available in the URL Bar 🤯
8// ie https://api.val.town/eval/"The first holiday is "+ @stevekrouse.basicAPIEx[0].name
4export const valBeeExample = async () => {
5 return (valbeeTest = fetchText(
6 "http://numbersapi.com/random/math"
7 ));
8};
12 twitterJSON({
13 url: handle
14 ? `https://api.twitter.com/2/users/by/username/${handle}`
15 : `https://api.twitter.com/2/users/${id}`,
16 bearerToken,
17 });
1import { discordAPI } from "https://esm.town/v/stevekrouse/discordAPI";
2
3// https://discord.com/developers/docs/resources/guild#get-guild-channels
4export let discordGetChannels = ({token, tokenType, guildId}) => discordAPI({
5 token,
6 tokenType,
1import { testMutateSemantics } from "https://esm.town/v/stevekrouse/testMutateSemantics";
2
3export const unauthenticatedCantMutate = (api) =>
4 testMutateSemantics({
5 stateName: "@stevekrouse.testState",
6 api,
7 mutateExpected: false,
8 mutator: (now) => `@stevekrouse.testState = ${now}`,
5 console.log(
6 await fetchText(
7 "https://api.val.town/v1/run/stevekrouse.id",
8 {
9 method: "POST",
15 console.log(
16 await fetchText(
17 "https://api.val.town/v1/run/stevekrouse.id",
18 {
19 method: "POST",
27 console.log(
28 await fetchText(
29 "https://api.val.town/v1/run/stevekrouse.id",
30 {
31 method: "POST",
5export let hasValTownStyleGuideUpdated = async (since: Date) => {
6 let commits = await fetchJSON(
7 "https://api.github.com/repos/val-town/val.town/commits?path=/src/style.tsx&since=" +
8 since.toISOString(),
9 {
4 const ics = await import("npm:ics");
5 const events = await fetch(
6 "https://a827-donatenyc.nyc.gov/DSNYApi/api/Events/GetAllByBorough?borough=",
7 )
8 .then((r) => r.json());
3export let chessTime = (async () => {
4 const { secondsToHours } = await import("npm:date-fns");
5 const stats = await fetch("https://lichess.org/api/user/tmcw").then((r) =>
6 r.json()
7 );