# Datasets ## List datasets `client.Radar.Datasets.List(ctx, query) (*DatasetListResponse, error)` **get** `/radar/datasets` Retrieves a list of datasets. ### Parameters - `query DatasetListParams` - `DatasetType param.Field[DatasetListParamsDatasetType]` Filters results by dataset type. - `const DatasetListParamsDatasetTypeRankingBucket DatasetListParamsDatasetType = "RANKING_BUCKET"` - `const DatasetListParamsDatasetTypeReport DatasetListParamsDatasetType = "REPORT"` - `Date param.Field[Time]` Filters results by the specified date. - `Format param.Field[DatasetListParamsFormat]` Format in which results will be returned. - `const DatasetListParamsFormatJson DatasetListParamsFormat = "JSON"` - `const DatasetListParamsFormatCsv DatasetListParamsFormat = "CSV"` - `Limit param.Field[int64]` Limits the number of objects returned in the response. - `Offset param.Field[int64]` Skips the specified number of objects before fetching the results. ### Returns - `type DatasetListResponse struct{…}` - `Datasets []DatasetListResponseDataset` - `ID int64` - `Description string` - `Meta unknown` - `Tags []string` - `Title string` - `Type string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/radar" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) datasets, err := client.Radar.Datasets.List(context.TODO(), radar.DatasetListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", 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(ctx, alias) (*string, error)` **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 - `type DatasetGetResponse string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) dataset, err := client.Radar.Datasets.Get(context.TODO(), "ranking_top_1000") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", dataset) } ``` ## Get dataset download URL `client.Radar.Datasets.Download(ctx, params) (*DatasetDownloadResponse, error)` **post** `/radar/datasets/download` Retrieves an URL to download a single dataset. ### Parameters - `params DatasetDownloadParams` - `DatasetID param.Field[int64]` Body param - `Format param.Field[DatasetDownloadParamsFormat]` Query param: Format in which results will be returned. - `const DatasetDownloadParamsFormatJson DatasetDownloadParamsFormat = "JSON"` - `const DatasetDownloadParamsFormatCsv DatasetDownloadParamsFormat = "CSV"` ### Returns - `type DatasetDownloadResponse struct{…}` - `Dataset DatasetDownloadResponseDataset` - `URL string` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/radar" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.Radar.Datasets.Download(context.TODO(), radar.DatasetDownloadParams{ DatasetID: cloudflare.F(int64(3)), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Dataset) } ``` #### Response ```json { "result": { "dataset": { "url": "https://example.com/download" } } } ```