Edits history of script submission #15832 for ' Get Contents (exa)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Exa = {
      apiKey: string;
    };
    /**
     * Get Contents
     *
     */
    export async function main(
      auth: Exa,
      body: { urls: string[]; ids?: string[] } & {
        text?:
          | false
          | true
          | { maxCharacters?: number; includeHtmlTags?: false | true };
        highlights?: {
          numSentences?: number;
          highlightsPerUrl?: number;
          query?: string;
        };
        summary?: { query?: string };
        livecrawl?: "never" | "fallback" | "always" | "auto";
        livecrawlTimeout?: number;
        subpages?: number;
        subpageTarget?: string | string[];
        extras?: { links?: number; imageLinks?: number };
      },
    ) {
      const url = new URL(`https://api.exa.ai/contents`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "X-API-Key": auth.apiKey,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago