# Datasets ## List datasets `client.radar.datasets.list(DatasetListParamsquery?, RequestOptionsoptions?): DatasetListResponse` **get** `/radar/datasets` Retrieves a list of datasets. ### Parameters - `query: DatasetListParams` - `datasetType?: "RANKING_BUCKET" | "REPORT"` Filters results by dataset type. - `"RANKING_BUCKET"` - `"REPORT"` - `date?: string` Filters results by the specified date. - `format?: "JSON" | "CSV"` Format in which results will be returned. - `"JSON"` - `"CSV"` - `limit?: number` Limits the number of objects returned in the response. - `offset?: number` Skips the specified number of objects before fetching the results. ### Returns - `DatasetListResponse` - `datasets: Array` - `id: number` - `description: string` - `meta: unknown` - `tags: Array` - `title: string` - `type: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const datasets = await client.radar.datasets.list(); console.log(datasets.datasets); ``` #### Response ```json { "result": { "datasets": [ { "id": 3, "description": "This dataset contains a list of the op 20000 domains globally", "meta": {}, "tags": [ "global" ], "title": "Top bucket 20000 domains", "type": "RANKING_BUCKET" } ] }, "success": true } ``` ## Get dataset CSV stream `client.radar.datasets.get(stringalias, RequestOptionsoptions?): DatasetGetResponse` **get** `/radar/datasets/{alias}` Retrieves the CSV content of a given dataset by alias or ID. When getting the content by alias the latest dataset is returned, optionally filtered by the latest available at a given date. ### Parameters - `alias: string` Dataset alias or ID. ### Returns - `DatasetGetResponse = string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const dataset = await client.radar.datasets.get('ranking_top_1000'); console.log(dataset); ``` ## Get dataset download URL `client.radar.datasets.download(DatasetDownloadParamsparams, RequestOptionsoptions?): DatasetDownloadResponse` **post** `/radar/datasets/download` Retrieves an URL to download a single dataset. ### Parameters - `params: DatasetDownloadParams` - `datasetId: number` Body param - `format?: "JSON" | "CSV"` Query param: Format in which results will be returned. - `"JSON"` - `"CSV"` ### Returns - `DatasetDownloadResponse` - `dataset: Dataset` - `url: string` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); const response = await client.radar.datasets.download({ datasetId: 3 }); console.log(response.dataset); ``` #### Response ```json { "result": { "dataset": { "url": "https://example.com/download" } } } ``` ## Domain Types ### Dataset List Response - `DatasetListResponse` - `datasets: Array` - `id: number` - `description: string` - `meta: unknown` - `tags: Array` - `title: string` - `type: string` ### Dataset Get Response - `DatasetGetResponse = string` ### Dataset Download Response - `DatasetDownloadResponse` - `dataset: Dataset` - `url: string`