API Reference
Endpoints, path parameters, authentication and sample requests
Last updated
Was this helpful?
Was this helpful?
# pip install tardis-dev
# requires Python >=3.9
from tardis_dev import download_datasets, get_exchange_details
import logging
import re
# comment out to disable debug logs
logging.basicConfig(level=logging.DEBUG)
# function used by default if not provided via options
def default_file_name(exchange, data_type, date, symbol, format):
sanitized_symbol = re.sub(r'[:\\/?*<>|"]', "-", symbol)
return f"{exchange}_{data_type}_{date.strftime('%Y-%m-%d')}_{sanitized_symbol}.{format}.gz"
# customized get filename function - saves data in nested directory structure
def file_name_nested(exchange, data_type, date, symbol, format):
sanitized_symbol = re.sub(r'[:\\/?*<>|"]', "-", symbol)
return f"{exchange}/{data_type}/{date.strftime('%Y-%m-%d')}_{sanitized_symbol}.{format}.gz"
# returns data available at https://api.tardis.dev/v1/exchanges/deribit
deribit_details = get_exchange_details("deribit")
# print(deribit_details)
download_datasets(
# one of https://api.tardis.dev/v1/exchanges with supportsDatasets:true - use 'id' value
exchange="deribit",
# accepted data types - 'datasets.symbols[].dataTypes' field in https://api.tardis.dev/v1/exchanges/deribit,
# or get those values from 'deribit_details["datasets"]["symbols"][i]["dataTypes"]' above
data_types=["incremental_book_L2", "trades", "quotes", "derivative_ticker", "book_snapshot_25", "book_snapshot_5", "liquidations"],
# change date ranges as needed to fetch full month or year for example
from_date="2019-11-01",
# to date is non inclusive
to_date="2019-11-02",
# accepted values: 'datasets.symbols[].id' field in https://api.tardis.dev/v1/exchanges/deribit
symbols=["BTC-PERPETUAL", "ETH-PERPETUAL",],
# (optional) your API key to get access to non sample data as well
api_key="YOUR API KEY",
# (optional) path where data will be downloaded into, default dir is './datasets'
# download_dir="./datasets",
# (optional) - one can customize downloaded file name/path (flat dir structure, or nested etc) - by default function 'default_file_name' is used
# get_filename=default_file_name,
# (optional) file_name_nested will download data to nested directory structure (split by exchange and data type)
# get_filename=file_name_nested,
)// npm install tardis-dev
// requires Node.js v24+
// remove it to disable debug logs
process.env.DEBUG = 'tardis-dev*'
import { downloadDatasets, getExchangeDetails } from 'tardis-dev'
// returns data available at https://api.tardis.dev/v1/exchanges/deribit
const deribitDetails = await getExchangeDetails('deribit')
// console.log(deribitDetails.datasets)
await downloadDatasets({
exchange: 'deribit', // one of https://api.tardis.dev/v1/exchanges with supportsDatasets:true - use 'id' value
dataTypes: ['incremental_book_L2', 'trades', 'quotes', 'derivative_ticker', 'book_snapshot_25', 'book_snapshot_5', 'liquidations'], // accepted data types - 'datasets.symbols[].dataTypes' field in https://api.tardis.dev/v1/exchanges/deribit, or get those values from 'deribitDetails.datasets.symbols[].dataTypes' object above
from: '2019-11-01', // change date ranges as needed to fetch full month or year for example
to: '2019-11-02', // to date is non inclusive
symbols: ['BTC-PERPETUAL', 'ETH-PERPETUAL'], // accepted values: 'datasets.symbols[].id' field in https://api.tardis.dev/v1/exchanges/deribit, or `deribitDetails.datasets.symbols[].id` from object above
apiKey: 'YOUR_API_KEY', // (optional) your API key to get access to non sample data as well
// downloadDir:'./datasets', // (optional) path where data will be downloaded into, default dir is './datasets'
// getFilename: getFilenameDefault, // (optional) - one can customize downloaded file name/path (flat dir structure, or nested etc) - by default function 'getFilenameDefault' is used
// getFilename: getFilenameCustom // (optional) getFilenameCustom will download data to nested directory structure (split by exchange and data type)
})
// function used by default if not provided via options
function sanitizeForFilename(value) {
return value.replace(/[:\\/?*<>|"]/g, '-')
}
function getFilenameDefault({ exchange, dataType, format, date, symbol }) {
return `${exchange}_${dataType}_${date.toISOString().split('T')[0]}_${sanitizeForFilename(symbol)}.${format}.gz`
}
// customized get filename function - saves data in nested directory structure
function getFilenameCustom({ exchange, dataType, format, date, symbol }) {
return `${exchange}/${dataType}/${date.toISOString().split('T')[0]}_${sanitizeForFilename(symbol)}.${format}.gz`
}