// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import { isRequestOptions } from 'cloudflare/core'; import * as RankingAPI from 'cloudflare/resources/radar/ranking/ranking'; import * as DomainAPI from 'cloudflare/resources/radar/ranking/domain'; export class Ranking extends APIResource { domain: DomainAPI.Domain = new DomainAPI.Domain(this._client); /** * Gets Domains Rank updates change over time. Raw values are returned. */ timeseriesGroups( query?: RankingTimeseriesGroupsParams, options?: Core.RequestOptions, ): Core.APIPromise; timeseriesGroups(options?: Core.RequestOptions): Core.APIPromise; timeseriesGroups( query: RankingTimeseriesGroupsParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(query)) { return this.timeseriesGroups({}, query); } return ( this._client.get('/radar/ranking/timeseries_groups', { query, ...options }) as Core.APIPromise<{ result: RankingTimeseriesGroupsResponse; }> )._thenUnwrap((obj) => obj.result); } /** * 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/. */ top(query?: RankingTopParams, options?: Core.RequestOptions): Core.APIPromise; top(options?: Core.RequestOptions): Core.APIPromise; top( query: RankingTopParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(query)) { return this.top({}, query); } return ( this._client.get('/radar/ranking/top', { query, ...options }) as Core.APIPromise<{ result: RankingTopResponse; }> )._thenUnwrap((obj) => obj.result); } } export interface RankingTimeseriesGroupsResponse { meta: RankingTimeseriesGroupsResponse.Meta; serie_0: RankingTimeseriesGroupsResponse.Serie0; } export namespace RankingTimeseriesGroupsResponse { export interface Meta { dateRange: Array; } export namespace Meta { export interface DateRange { /** * Adjusted end of date range. */ endTime: string; /** * Adjusted start of date range. */ startTime: string; } } export interface Serie0 { timestamps: Array; [k: string]: Array; } } export interface RankingTopResponse { meta: RankingTopResponse.Meta; top_0: Array; } export namespace RankingTopResponse { export interface Meta { top_0: Meta.Top0; } export namespace Meta { export interface Top0 { date: string; } } export interface Top0 { categories: Array; domain: string; rank: number; /** * Only available in TRENDING rankings. */ pctRankChange?: number; } export namespace Top0 { export interface Category { id: number; name: string; superCategoryId: number; } } } export interface RankingTimeseriesGroupsParams { /** * End of the date range (inclusive). */ dateEnd?: Array; /** * For example, use `7d` and `7dControl` to compare this week with the previous * week. Use this parameter or set specific start and end dates (`dateStart` and * `dateEnd` parameters). */ dateRange?: Array< | '1d' | '2d' | '7d' | '14d' | '28d' | '12w' | '24w' | '52w' | '1dControl' | '2dControl' | '7dControl' | '14dControl' | '28dControl' | '12wControl' | '24wControl' >; /** * Array of datetimes to filter the start of a series. */ dateStart?: Array; /** * Array of comma separated list of domains names. */ domains?: Array; /** * Format results are returned in. */ format?: 'JSON' | 'CSV'; /** * Limit the number of objects in the response. */ limit?: number; /** * Array of locations (alpha-2 country codes). */ location?: Array; /** * Array of names that will be used to name the series in responses. */ name?: Array; /** * The ranking type. */ rankingType?: 'POPULAR' | 'TRENDING_RISE' | 'TRENDING_STEADY'; } export interface RankingTopParams { /** * Array of dates to filter the ranking. */ date?: Array; /** * Format results are returned in. */ format?: 'JSON' | 'CSV'; /** * Limit the number of objects in the response. */ limit?: number; /** * Array of locations (alpha-2 country codes). */ location?: Array; /** * Array of names that will be used to name the series in responses. */ name?: Array; /** * The ranking type. */ rankingType?: 'POPULAR' | 'TRENDING_RISE' | 'TRENDING_STEADY'; } export namespace Ranking { export import RankingTimeseriesGroupsResponse = RankingAPI.RankingTimeseriesGroupsResponse; export import RankingTopResponse = RankingAPI.RankingTopResponse; export import RankingTimeseriesGroupsParams = RankingAPI.RankingTimeseriesGroupsParams; export import RankingTopParams = RankingAPI.RankingTopParams; export import Domain = DomainAPI.Domain; export import DomainGetResponse = DomainAPI.DomainGetResponse; export import DomainGetParams = DomainAPI.DomainGetParams; }