1import { fetch } from "https://esm.town/v/std/fetch";
2
3export let fetchABird = async () => {
4 const MAX_ID = 777905;
5 const baseUrl = "https://xeno-canto.org/api/2/recordings";
6 const minAnimalId = Math.floor(Math.random() * (MAX_ID + 10));
7 const query = `?query=nr:${minAnimalId}-${minAnimalId + 10}`;
8 const response = await fetch(`${baseUrl}${query}`);
9 const json = await response.json();
10 return json.recordings[Math.floor(Math.random() * 9)];
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const fourchan_catalog = (board: string) =>
4 fetchJSON(`https://a.4cdn.org/${board}/catalog.json`);
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3export const isCloseToCitibikeStation = async ({ lon, lat }) => {
7 const dist = (station) =>
8 Math.sqrt(Math.pow(station.lat - lat, 2) + Math.pow(station.lon - lon, 2));
9 const { data } = await fetchJSON(
10 "https://gbfs.citibikenyc.com/gbfs/en/station_information.json",
11 );
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// GitHub repos
4export let githubRepos = fetchJSON(
5 "https://api.github.com/users/stevekrouse/repos"
6);
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function pug(
14 const { default: genCode } = await pugCodegen;
15 const pugFnStr = genCode(parser.parse(), { inlineRuntimeFunctions: true });
16 const evalResp = await fetch("https://api.val.town/v1/eval", {
17 method: "POST",
18 body: JSON.stringify({
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const nyChargingStations = (async () => {
5 const { group } = await import("npm:d3-array");
6 const { micromark } = await import("npm:micromark");
7 const rows = await fetch(
8 "https://data.ny.gov/api/views/7rrd-248n/rows.csv?accessType=DOWNLOAD&sorting=true",
9 )
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export let evalPost1 = fetchJSON(
4 "https://api.val.town/v1/eval",
5 {
1import { email } from "https://esm.town/v/std/email?v=9";
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function fetchCongressTradeReports({ lastRunAt }) {
5 const res = await fetchJSON(
6 "https://bff.capitoltrades.com/trades?sortBy=-pubDate",
7 );
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Reddit recent posts from /r/aww (cute animals)
4export let subredditExample = fetchJSON(
5 "https://www.reddit.com/r/aww/.json"
6);
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export const simpleSurf = (async () => {
4 // fetch these from the surfline page
5 const spotIds = [
6 "5842041f4e65fad6a770883f",
11 ];
12 const spots = spotIds.join(",");
13 const surfForecast = await fetch(
14 `https://services.surfline.com/kbyg/spots/batch?units%5BswellHeight%5D=FT&units%5Btemperature%5D=F&units%5BtideHeight%5D=FT&units%5BwaveHeight%5D=FT&units%5BwindSpeed%5D=KTS&spotIds=${spots}`,
15 ).then((r) => r.json()).then((d) => d.data);