Edits history of script submission #5410 for ' Get Top or Trending Domains (cloudflare)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Get Top or Trending Domains
     * Get top or trending domains based on their rank. Popular domains are domains of broad appeal based on how people use the Internet. Trending domains are domains that are generating a surge in interest. For more information on top domains, see https://blog.cloudflare.com/radar-domain-rankings/.
     */
    export async function main(
      auth: Cloudflare,
      limit: string | undefined,
      name: string | undefined,
      location: string | undefined,
      date: string | undefined,
      rankingType: "POPULAR" | "TRENDING_RISE" | "TRENDING_STEADY" | undefined,
      format: "JSON" | "CSV" | undefined
    ) {
      const url = new URL(`https://api.cloudflare.com/client/v4/radar/ranking/top`);
      for (const [k, v] of [
        ["limit", limit],
        ["name", name],
        ["location", location],
        ["date", date],
        ["rankingType", rankingType],
        ["format", format],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          "X-AUTH-EMAIL": auth.email,
          "X-AUTH-KEY": auth.key,
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 383 days ago

  • nativets
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Get Top or Trending Domains
     * Get top or trending domains based on their rank. Popular domains are domains of broad appeal based on how people use the Internet. Trending domains are domains that are generating a surge in interest. For more information on top domains, see https://blog.cloudflare.com/radar-domain-rankings/.
     */
    export async function main(
      auth: Cloudflare,
      limit: string | undefined,
      name: string | undefined,
      location: string | undefined,
      date: string | undefined,
      rankingType: "POPULAR" | "TRENDING_RISE" | "TRENDING_STEADY" | undefined,
      format: "JSON" | "CSV" | undefined
    ) {
      const url = new URL(`https://api.cloudflare.com/client/v4/radar/ranking/top`);
      for (const [k, v] of [
        ["limit", limit],
        ["name", name],
        ["location", location],
        ["date", date],
        ["rankingType", rankingType],
        ["format", format],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "GET",
        headers: {
          "X-AUTH-EMAIL": auth.email,
          "X-AUTH-KEY": auth.key,
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 920 days ago