13
14 try {
15 const searchUrl = `https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=${
16 encodeURIComponent(searchQuery)
17 }&srwhat=text&format=json&utf8=1&origin=*`;
27
28 const pageTitle = searchData.query.search[0].title;
29 const contentUrl = `https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exintro&titles=${
30 encodeURIComponent(pageTitle)
31 }&format=json&utf8=1&origin=*`;
4export async function quote_of_the_day() {
5 const [qod] = await fetchJSON(
6 "https://zenquotes.io/api/today",
7 );
8 const formattedQuote = `"${qod.q}"
10 }
11
12 const weatherApiUrl = `https://wttr.in/${encodeURIComponent(city)}?format=j1`;
13
14 try {
15 const weatherResponse = await fetch(weatherApiUrl);
16 if (!weatherResponse.ok) {
17 throw new Error(`Weather API request failed with status: ${weatherResponse.status}`);
18 }
19 const weatherData = await weatherResponse.json();
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
2
3// Explore the Star Wars universe, from StarWarsAPI
4export let starWars = fetchJSON(
5 "https://swapi.dev/api/people/1/",
6);
9async function fetchRandomJoke() {
10 const response = await fetch(
11 "https://official-joke-api.appspot.com/random_joke",
12 );
13 return response.json();
2
3export function getMe(): Promise<{ username: string; id: string; profileImageUrl; bio: string }> {
4 return fetchJSON("https://api.val.town/v1/me", {
5 headers: {
6 Authorization: `Bearer ${Deno.env.get("valtown")}`,
15 const birdName = bird.en.replace(" ", "+");
16 newState.data.content_url =
17 `https://api.val.town/express/@crsven.embedBirdSound?args=${birdName},${bird.file},${photoUrl}`;
18 newState.layouts.hello_small.styles.colors.background.color = colorCombo.background;
19 newState.layouts.hello_small.styles.colors.text.color = colorCombo.text;
1export function myApi(name) {
2 return "hi " + name;
3}
35
36async function getMarket(slug: string) {
37 const res = await fetch(`https://api.manifold.markets/v0/slug/${slug}`);
38
39 if (!res.ok) {
20
21async function getNewThreads() {
22 const resp = await fetch(`https://discord.com/api/guilds/${guild}/threads/active`, {
23 headers: {
24 "Authorization": `Bot ${token}`,