0

List Insights

by
Published Oct 17, 2025
Script tomorrow Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Tomorrow = {
3
  apiKey: string;
4
};
5
/**
6
 * List Insights
7
 *
8
 */
9
export async function main(auth: Tomorrow, Accept_Encoding?: string) {
10
  const url = new URL(`https://api.tomorrow.io/v4/insights`);
11

12
  const response = await fetch(url, {
13
    method: "GET",
14
    headers: {
15
      ...(Accept_Encoding ? { "Accept-Encoding": Accept_Encoding } : {}),
16
      ApiKey: auth.apiKey,
17
    },
18
    body: undefined,
19
  });
20
  if (!response.ok) {
21
    const text = await response.text();
22
    throw new Error(`${response.status} ${text}`);
23
  }
24
  return await response.json();
25
}
26