// npm install tardis-dev
// requires node version >=12
const { downloadDatasets, getExchangeDetails } = require('tardis-dev')
const exchange = 'bitmex'
const exchangeDetails = await getExchangeDetails(exchange)
// iterate over and download all data for every symbol
for (const symbol of exchangeDetails.datasets.symbols) {
// alternatively specify dataTypes explicitly ['trades', 'incremental_book_L2', 'quotes'] etc
// see available options https://docs.tardis.dev/downloadable-csv-files#data-types
const dataTypes = symbol.dataTypes
const symbolId = symbol.id
const from = symbol.availableSince
const to = symbol.availableTo
if (['PERPETUALS', 'SPOT', 'FUTURES'].includes(symbolId)) {
console.log(`Downloading ${exchange} ${dataTypes} for ${symbolId} from ${from} to ${to}`)
// each CSV dataset format is documented at https://docs.tardis.dev/downloadable-csv-files#data-types
// see https://docs.tardis.dev/downloadable-csv-files#download-via-client-libraries for full options docs
// TODO: set your API key here
// path where CSV data will be downloaded into
downloadDir: './datasets'