35}
36
37export const apis = {
38 twemoji: (code: string) =>
39 `https://cdnjs.cloudflare.com/ajax/libs/twemoji/14.0.2/svg/${
56const emojiCache: Record<string, Promise<string>> = {};
57
58export async function loadEmoji (type: keyof typeof apis, code: string) {
59 const key = `${type}:${code}`;
60
63 }
64
65 if (!type || !apis[type]) {
66 type = "twemoji";
67 }
68
69 const api = apis[type];
70
71 if (typeof api === "function") {
72 return (emojiCache[key] = fetch(api(code)).then(async r => r.text()));
73 }
74 return (emojiCache[key] = fetch(`${api}${code.toUpperCase()}.svg`).then(async r =>
75 r.text()));
76}
2import process from "node:process";
3
4/** Must set process.env.WEATHER_API_KEY for weatherapi.com **/
5export async function getWeather(
6 query: string,
7 days = 10,
8): Promise<WeatherApiResponse> {
9 const weatherApiKey = process.env.WEATHER_API_KEY;
10 const q = encodeURIComponent(query);
11 const apiUrl = `https://api.weatherapi.com/v1/forecast.json?key=${weatherApiKey}&q=${q}&days=${days}`;
12 const response = await fetch(apiUrl);
13 const data: any = await response.json();
14 return data;
15}
16
17type WeatherApiResponse = {
18 location: {
19 name: string;
1API:`https://nishui-MusicAPI2.web.val.run?id=xxx`
2
3id 是网易云的音乐 id 值,使用此 API 将会访问网页的两个 API 去获取音乐信息和歌词信息
4
5我们用 req.url 获取 API 的url,然后再获取 url 的参数 id,这样就获取到对应的参数 id 了
6
72024年03月25日 不知道什么原因,获取 song 的 detail 失败,说是 `querystring/url must match format \"uri\`
8
9Migrated from folder: MusicPlatform/MusicAPI2
6 const account = searchParams.get("account");
7 const mode = searchParams.get("mode");
8 const SOURCE_URL = `https://boards-api.greenhouse.io/v1/boards/${account}/jobs`;
9 const { jobs: sourceJobs } = await fetch(SOURCE_URL).then((res) => res.json());
10
12 const feed = new Feed({
13 title: `Jobs: ${account} (via Greenhouse)`,
14 description: "Job postings automatically forwarded from Greenhouse API to RSS.",
15 id: getFeedLink(mode),
16 link: "https://www.val.town/v/donmccurdy.greenhouseToRSS",
7 const account = searchParams.get("account");
8 const mode = searchParams.get("mode");
9 const SOURCE_URL = `https://api.lever.co/v0/postings/${account}?mode=xml`;
10 const parser = new XMLParser();
11 const sourceXML = await fetch(SOURCE_URL).then((res) => res.text());
39 };
40
41 return fetchJSON("https://api.val.town/v1/vals", {
42 headers: {
43 Authorization: `Bearer ${token}`,
20 };
21
22 return fetchJSON(`https://api.val.town/v1/vals/${valId}`, {
23 headers: {
24 Authorization: `Bearer ${token}`,
14 };
15
16 return fetchJSON("https://api.val.town/v1/vals", {
17 headers: {
18 Authorization: `Bearer ${token}`,
35 </li>
36 <li>If your access token expires, we use the refresh token to get a new one.</li>
37 <li>Use your access token to make requests to the Spotify API.</li>
38 </ol>
39
1Migrated from folder: External_APIs/spotify/spotify_helpers