### Python Client Example Source: https://docs.tardis.dev/historical-data-details/crypto-com Example of how to use the Python client library to replay historical data from Crypto.com. Requires installation of the 'tardis-dev' package. ```APIDOC ## Python Client ### Description Use the Python client to replay historical data from Crypto.com. ### Method `replay` function ### Parameters - **exchange** (string) - Required - The exchange name, e.g., "crypto-com". - **from_date** (string) - Required - The start date for historical data (YYYY-MM-DD). - **to_date** (string) - Required - The end date for historical data (YYYY-MM-DD). - **filters** (list of Channel objects) - Required - Specifies the data channels and symbols to retrieve. Example: `[Channel(name="book", symbols=["BTCUSD-PERP"])]`. - **api_key** (string) - Required - Your Tardis API key. ### Request Example ```python # pip install tardis-dev import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="crypto-com", from_date="2024-01-01", to_date="2024-01-02", filters=[Channel(name="book", symbols=["BTCUSD-PERP"])], api_key="YOUR_API_KEY", ): # messages as provided by Crypto.com exchange real-time stream print(message) asyncio.run(main()) ``` ### Response - **local_timestamp** (int) - The local timestamp of the message. - **message** (dict) - The historical data message from Crypto.com. ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/bitmex Example of how to use the Python client library to fetch historical BitMEX data. Requires installation of the 'tardis-dev' package. ```APIDOC ## Python Client for BitMEX Historical Data ### Description This snippet demonstrates how to use the `tardis-dev` Python library to replay historical market data from BitMEX. It allows specifying date ranges, channels, and symbols. ### Usage 1. Install the library: `pip install tardis-dev` 2. Replace `'YOUR_API_KEY'` with your actual API key. 3. Run the script. ### Code Example ```python import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="bitmex", from_date="2023-03-01", to_date="2023-03-02", filters=[Channel(name="orderBookL2_25", symbols=["XBTUSD"])], api_key="YOUR_API_KEY", ): # messages as provided by BitMEX real-time stream print(message) asyncio.run(main()) ``` ### Further Information See [Python client docs](https://docs.tardis.dev/python-client/quickstart) for more details. ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/bitmex Example of how to use the Node.js client library to fetch historical BitMEX data. Requires installation of the 'tardis-dev' package. ```APIDOC ## Node.js Client for BitMEX Historical Data ### Description This snippet demonstrates how to use the `tardis-dev` Node.js library to replay historical market data from BitMEX. It allows specifying date ranges, channels, and symbols. ### Usage 1. Install the library: `npm install tardis-dev` 2. Replace `'YOUR_API_KEY'` with your actual API key. 3. Run the script. ### Code Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'bitmex', from: '2023-03-01', to: '2023-03-02', filters: [{ channel: 'orderBookL2_25', symbols: ['XBTUSD'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by BitMEX real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ### Further Information See [Node.js client docs](https://docs.tardis.dev/node-client/quickstart) for more details. ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/crypto-com Example of how to use the Node.js client library to replay historical data from Crypto.com. Requires installation of the 'tardis-dev' package. ```APIDOC ## Node.js Client ### Description Use the Node.js client to replay historical data from Crypto.com. ### Method `replay` function ### Parameters - **exchange** (string) - Required - The exchange name, e.g., "crypto-com". - **from** (string) - Required - The start date for historical data (YYYY-MM-DD). - **to** (string) - Required - The end date for historical data (YYYY-MM-DD). - **filters** (array of objects) - Required - Specifies the data channels and symbols to retrieve. Example: `[{ channel: 'book', symbols: ['BTCUSD-PERP'] }]`. - **apiKey** (string) - Required - Your Tardis API key. ### Request Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'crypto-com', from: '2024-01-01', to: '2024-01-02', filters: [{ channel: 'book', symbols: ['BTCUSD-PERP'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by Crypto.com exchange real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ### Response - **localTimestamp** (number) - The local timestamp of the message. - **message** (object) - The historical data message from Crypto.com. ``` -------------------------------- ### HTTP API Example Source: https://docs.tardis.dev/historical-data-details/bybit-spot Example of how to fetch Bybit Spot historical data using a direct HTTP GET request. This snippet shows how to request order book data for a specific date. ```APIDOC ## Fetch Bybit Spot Historical Data (HTTP API) ### Description This example demonstrates how to retrieve historical market data for Bybit Spot using the HTTP API. It fetches order book data for a specified date. ### Method GET ### Endpoint `/v1/data-feeds/bybit-spot` ### Query Parameters - `from` (string): The start date for the data retrieval (YYYY-MM-DD). - `filters` (string): A JSON string representing the data channels and symbols to fetch. Example: `"[{"channel":"orderbook.50","symbols":["BTCUSDT"]}]"`. - `offset` (integer): The offset for pagination, defaults to 0. ### Request Example ```bash curl --compressed -g 'https://api.tardis.dev/v1/data-feeds/bybit-spot?from=2024-01-01&filters=[{"channel":"orderbook.50","symbols":["BTCUSDT"]}]&offset=0' ``` ### Response - The response contains historical data in the format provided by Bybit Spot real-time WebSocket API. ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/bitfinex Example of how to use the Python client library to replay historical data from Bitfinex. ```APIDOC ## Python Client Example ### Description This snippet demonstrates how to fetch historical Bitfinex data using the Python client library. It shows how to specify date ranges, filters for channels and symbols, and requires an API key. ### Method `replay` function from `tardis_dev` library ### Parameters - `exchange` (string): The exchange name, e.g., "bitfinex". - `from_date` (string): The start date for the data retrieval (YYYY-MM-DD). - `to_date` (string): The end date for the data retrieval (YYYY-MM-DD). - `filters` (list of Channel objects): Specifies the data channels and symbols to retrieve. Example: `[Channel(name="book", symbols=["BTCUSD"])]`. - `api_key` (string): Your Tardis API key. ### Code Example ```python # pip install tardis-dev import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="bitfinex", from_date="2023-03-01", to_date="2023-03-02", filters=[Channel(name="book", symbols=["BTCUSD"])], api_key="YOUR_API_KEY", ): # messages as provided by Bitfinex real-time stream print(message) asyncio.run(main()) ``` ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/binance-dex Example of how to use the Python client to replay historical data from Binance DEX. ```APIDOC ## Python Client ### Description Use the `tardis-dev` Python library to fetch historical data from Binance DEX. ### Usage ```python # pip install tardis-dev import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="binance-dex", from_date="2020-01-01", to_date="2020-01-02", filters=[Channel(name="marketDiff", symbols=["BTCB-1DE_BUSD-BD1"])], api_key="YOUR_API_KEY", ): # messages as provided by Binance DEX real-time stream print(message) asyncio.run(main()) ``` See [Python client docs](https://docs.tardis.dev/python-client/quickstart). ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/bitfinex Example of how to use the Node.js client library to replay historical data from Bitfinex. ```APIDOC ## Node.js Client Example ### Description This snippet shows how to retrieve historical Bitfinex data using the Node.js client library. It allows specifying date ranges, filters, and requires an API key. ### Method `replay` function from `tardis-dev` package ### Parameters - `exchange` (string): The exchange name, e.g., "bitfinex". - `from` (string): The start date for the data retrieval (YYYY-MM-DD). - `to` (string): The end date for the data retrieval (YYYY-MM-DD). - `filters` (array of objects): Specifies the data channels and symbols. Example: `[{ channel: 'book', symbols: ['BTCUSD'] }]`. - `apiKey` (string): Your Tardis API key. ### Code Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'bitfinex', from: '2023-03-01', to: '2023-03-02', filters: [{ channel: 'book', symbols: ['BTCUSD'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by Bitfinex real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/ftx-us Example of how to use the Python client library to replay historical data from FTX US. ```APIDOC ## Python Client Example ### Description This example demonstrates how to fetch historical market data for FTX US using the Python client library. It allows you to specify a date range, filter by channels and symbols, and retrieve messages in the format provided by the FTX US real-time stream. ### Method `replay` function from the `tardis_dev` library ### Parameters - `exchange` (string): The exchange identifier, e.g., "ftx-us". - `from_date` (string): The start date for historical data (YYYY-MM-DD). - `to_date` (string): The end date for historical data (YYYY-MM-DD). - `filters` (list of Channel objects): A list specifying the data channels and symbols to retrieve. Example: `[Channel(name="orderbook", symbols=["BTC/USD"])]`. - `api_key` (string): Your Tardis API key. ### Request Example ```python # pip install tardis-dev import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="ftx-us", from_date="2022-01-01", to_date="2022-01-02", filters=[Channel(name="orderbook", symbols=["BTC/USD"])], api_key="YOUR_API_KEY", ): # messages as provided by FTX US real-time stream print(message) asyncio.run(main()) ``` ### Response - `local_timestamp` (int): The local timestamp of the message. - `message` (dict): The historical market data message in the format provided by FTX US real-time streams. ``` -------------------------------- ### HTTP API Example Source: https://docs.tardis.dev/historical-data-details/binance-delivery Example of how to request historical data for Binance COIN Futures using the HTTP API. This demonstrates fetching 'depth' data for 'btcusd_perp' starting from a specific date. ```APIDOC ## HTTP API for Binance COIN Futures Historical Data ### Description This section provides an example of how to query historical market data for Binance COIN Futures directly via the HTTP API. It shows a `curl` command to fetch 'depth' data for a given symbol and date range. ### Method `GET` ### Endpoint `/v1/data-feeds/binance-delivery` ### Query Parameters - **from** (string) - Required - The start date for the data retrieval (YYYY-MM-DD). - **filters** (string) - Required - A JSON string representing the data filters, including channel and symbols. - **offset** (integer) - Optional - Offset for pagination. ### Request Example (cURL) ```bash curl --compressed -g 'https://api.tardis.dev/v1/data-feeds/binance-delivery?from=2023-03-01&filters=[{"channel":"depth","symbols":["btcusd_perp"]}]&offset=0' ``` ### Further Information Consult the [HTTP API docs](https://docs.tardis.dev/api/http-api-reference) for a complete reference. ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/binance-dex Example of how to use the Node.js client to replay historical data from Binance DEX. ```APIDOC ## Node.js Client ### Description Use the `tardis-dev` Node.js library to fetch historical data from Binance DEX. ### Usage ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'binance-dex', from: '2020-01-01', to: '2020-01-02', filters: [{ channel: 'marketDiff', symbols: ['BTCB-1DE_BUSD-BD1'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by Binance DEX real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` See [Node.js client docs](https://docs.tardis.dev/node-client/quickstart). ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/poloniex Example of how to use the Python client library to replay historical data from Poloniex. ```APIDOC ## Python Client for Poloniex Historical Data ### Description This snippet demonstrates how to fetch historical market data from Poloniex using the `tardis-dev` Python client. It allows specifying a date range and filtering by channel and symbols. ### Usage 1. Install the library: `pip install tardis-dev` 2. Replace `YOUR_API_KEY` with your actual API key. 3. Run the script. ### Code Example ```python import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="poloniex", from_date="2024-01-01", to_date="2024-01-02", filters=[Channel(name="book_lv2", symbols=["BTC_USDT"])], api_key="YOUR_API_KEY", ): # messages as provided by Poloniex real-time stream print(message) asyncio.run(main()) ``` ### Further Information See [Python client docs](https://docs.tardis.dev/python-client/quickstart) for more details. ``` -------------------------------- ### HTTP API Example Source: https://docs.tardis.dev/historical-data-details/binance-dex Example of how to fetch historical data from Binance DEX using the HTTP API. ```APIDOC ## HTTP API ### Description Fetch historical market data for Binance DEX directly via the HTTP API. ### Method `GET` ### Endpoint `/v1/data-feeds/binance-dex` ### Query Parameters - **from** (string) - Required - Start date for the data (YYYY-MM-DD). - **filters** (array of objects) - Required - Specifies the channels and symbols to retrieve. Each object should have a `channel` (string) and optionally `symbols` (array of strings). - **offset** (integer) - Optional - Offset for pagination. ### Request Example ```bash curl --compressed -g 'https://api.tardis.dev/v1/data-feeds/binance-dex?from=2020-01-01&filters=[{"channel":"marketDiff","symbols":["BTCB-1DE_BUSD-BD1"]}]&offset=0' ``` See [HTTP API docs](https://docs.tardis.dev/api/http-api-reference). ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/poloniex Example of how to use the Node.js client library to replay historical data from Poloniex. ```APIDOC ## Node.js Client for Poloniex Historical Data ### Description This snippet shows how to retrieve historical market data from Poloniex using the `tardis-dev` Node.js client. You can specify the date range and filter data by channel and symbols. ### Usage 1. Install the library: `npm install tardis-dev` 2. Replace `YOUR_API_KEY` with your actual API key. 3. Execute the script. ### Code Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'poloniex', from: '2024-01-01', to: '2024-01-02', filters: [{ channel: 'book_lv2', symbols: ['BTC_USDT'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by Poloniex real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ### Further Information Refer to the [Node.js client docs](https://docs.tardis.dev/node-client/quickstart) for comprehensive usage instructions. ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/ftx-us Example of how to use the Node.js client library to replay historical data from FTX US. ```APIDOC ## Node.js Client Example ### Description This example shows how to retrieve historical market data for FTX US using the Node.js client library. You can specify the exchange, date range, and data filters to get messages in the FTX US real-time stream format. ### Method `replay` function from the `tardis-dev` library ### Parameters - `exchange` (string): The exchange identifier, e.g., "ftx-us". - `from` (string): The start date for historical data (YYYY-MM-DD). - `to` (string): The end date for historical data (YYYY-MM-DD). - `filters` (array of objects): An array of filter objects, each specifying a channel and symbols. Example: `[{ channel: 'orderbook', symbols: ['BTC/USD'] }]`. - `apiKey` (string): Your Tardis API key. ### Request Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'ftx-us', from: '2022-01-01', to: '2022-01-02', filters: [{ channel: 'orderbook', symbols: ['BTC/USD'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by FTX US real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ### Response - `localTimestamp` (number): The local timestamp of the message. - `message` (object): The historical market data message in the format provided by FTX US real-time streams. ``` -------------------------------- ### Query Documentation via HTTP GET Source: https://docs.tardis.dev/historical-data-details/okex-swap Perform an HTTP GET request to query the documentation dynamically. Use the 'ask' query parameter with a specific, self-contained question in natural language to get direct answers and relevant excerpts. ```http GET https://docs.tardis.dev/historical-data-details/okex-swap.md?ask= ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/bitfinex-derivatives Example of how to use the Python client library to fetch historical Bitfinex derivative data. ```APIDOC ## Python Client ### Description Use the `tardis-dev` Python library to replay historical market data. ### Method `replay` function ### Parameters - `exchange` (string) - Required - The exchange name, e.g., "bitfinex-derivatives". - `from_date` (string) - Required - The start date for the data retrieval (YYYY-MM-DD). - `to_date` (string) - Optional - The end date for the data retrieval (YYYY-MM-DD). - `filters` (list of Channel objects) - Required - Specifies the data channels and symbols to subscribe to. Example: `[Channel(name="book", symbols=["BTCF0:USTF0"])]`. - `api_key` (string) - Required - Your Tardis API key. ### Response An asynchronous generator yielding tuples of `(local_timestamp, message)`. ### Request Example ```python # pip install tardis-dev import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="bitfinex-derivatives", from_date="2023-03-01", to_date="2023-03-02", filters=[Channel(name="book", symbols=["BTCF0:USTF0"])], api_key="YOUR_API_KEY", ): # messages as provided by Bitfinex real-time stream print(message) asyncio.run(main()) ``` ``` -------------------------------- ### Run Tardis Machine with npx Source: https://docs.tardis.dev/tardis-machine/quickstart Installs and runs the Tardis Machine server using npx. This is a convenient way to start the server without a global installation. ```bash npx tardis-machine --api-key=YOUR_API_KEY ``` -------------------------------- ### Run Tardis Machine after Global npm Install Source: https://docs.tardis.dev/tardis-machine/quickstart Runs the Tardis Machine server after it has been installed globally via npm. This command starts the server with the provided API key. ```bash tardis-machine --api-key=YOUR_API_KEY ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/bybit Example of how to use the Python client library to replay historical data from Bybit Derivatives. ```APIDOC ## Python Client Example ### Description This snippet demonstrates how to fetch historical Bybit Derivatives data using the Python client library. It shows how to specify the exchange, date range, desired channels, and symbols, and how to process the received messages. ### Method `replay` function from `tardis_dev` library ### Parameters - **exchange** (string) - Required - The name of the exchange (e.g., "bybit"). - **from_date** (string) - Required - The start date for the data retrieval (YYYY-MM-DD). - **to_date** (string) - Required - The end date for the data retrieval (YYYY-MM-DD). - **filters** (list of Channel objects) - Required - A list specifying the data channels and symbols to retrieve. - **Channel.name** (string) - The name of the channel (e.g., "orderbook.50"). - **Channel.symbols** (list of strings) - The trading symbols to subscribe to (e.g., ["BTCUSD"]). - **api_key** (string) - Required - Your Tardis API key. ### Response - **local_timestamp** (integer) - The timestamp of the received message. - **message** (dict) - The historical data message in the format provided by Bybit Derivatives real-time stream. ### Request Example ```python # pip install tardis-dev import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="bybit", from_date="2024-01-01", to_date="2024-01-02", filters=[Channel(name="orderbook.50", symbols=["BTCUSD"])], api_key="YOUR_API_KEY", ): # messages as provided by Bybit Derivatives real-time stream print(message) asyncio.run(main()) ``` ``` -------------------------------- ### Download Binance COIN Futures CSV Sample Source: https://docs.tardis.dev/historical-data-details/binance-delivery Provides direct download links for sample CSV files of Binance COIN Futures historical data. These files are available for the first day of each month and do not require an API key. ```bash https://datasets.tardis.dev/v1/binance-delivery/incremental_book_L2/2020/07/01/BTCUSD_200925.csv.gz ``` ```bash https://datasets.tardis.dev/v1/binance-delivery/trades/2020/07/01/BTCUSD_200925.csv.gz ``` ```bash https://datasets.tardis.dev/v1/binance-delivery/derivative_ticker/2020/07/01/BTCUSD_200925.csv.gz ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/bybit-spot Example of how to fetch Bybit Spot historical data using the Python client library. This code snippet demonstrates fetching order book data for a specified date range. ```APIDOC ## Fetch Bybit Spot Historical Data (Python) ### Description This example shows how to retrieve historical market data for Bybit Spot using the Python client. It fetches order book data between two specified dates. ### Method `replay` function from `tardis_dev` library ### Parameters - `exchange` (string): The exchange name, e.g., "bybit-spot". - `from_date` (string): The start date for the data retrieval (YYYY-MM-DD). - `to_date` (string): The end date for the data retrieval (YYYY-MM-DD). - `filters` (list of Channel objects): Specifies the data channels and symbols to fetch. Example: `[Channel(name="orderbook.50", symbols=["BTCUSDT"])]`. - `api_key` (string): Your Tardis API key. ### Request Example ```python import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="bybit-spot", from_date="2024-01-01", to_date="2024-01-02", filters=[Channel(name="orderbook.50", symbols=["BTCUSDT"])], api_key="YOUR_API_KEY", ): print(message) asyncio.run(main()) ``` ### Response - `local_timestamp` (int): The local timestamp of the data point. - `message` (dict): The historical data message in the format provided by Bybit Spot real-time stream. ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/okex-options Example of how to use the Python client library to fetch historical OKX options data. This code snippet demonstrates fetching data for a specified date range and channel. ```APIDOC ## Python Client Example ### Description This example demonstrates how to use the `tardis-dev` Python client to retrieve historical OKX options data. It shows how to specify the exchange, date range, filters (channels and symbols), and API key. ### Method `replay` function from `tardis_dev` library ### Parameters - `exchange` (string): The exchange name, e.g., "okex-options". - `from_date` (string): The start date for the historical data (YYYY-MM-DD). - `to_date` (string): The end date for the historical data (YYYY-MM-DD). - `filters` (list of Channel objects): A list specifying the data channels and symbols to retrieve. Example: `[Channel(name="books-l2-tbt", symbols=[])]`. - `api_key` (string): Your Tardis API key. ### Request Example ```python # pip install tardis-dev import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="okex-options", from_date="2024-01-01", to_date="2024-01-02", filters=[Channel(name="books-l2-tbt", symbols=[])], api_key="YOUR_API_KEY", ): # messages as provided by OKX real-time stream print(message) asyncio.run(main()) ``` ### Response - `local_timestamp` (int): The local timestamp of the message. - `message` (dict): The historical data message as provided by the OKX real-time stream. ``` -------------------------------- ### Get Deribit Data Feed Source: https://docs.tardis.dev/api/http-api-reference Retrieves a data feed for Deribit. Specify the 'from' parameter for the start timestamp and 'offset' for pagination. ```http https://api.tardis.dev/v1/data-feeds/deribit?from=2019-06-01&offset=10 ``` -------------------------------- ### Download OKX Swap Incremental Book L2 Sample Data Source: https://docs.tardis.dev/historical-data-details/okex-swap Provides a direct download link for a sample CSV.gz file of incremental book L2 data for BTC-USD-SWAP on 2020-01-01. ```bash https://datasets.tardis.dev/v1/okex-swap/incremental_book_L2/2020/01/01/BTC-USD-SWAP.csv.gz ``` -------------------------------- ### Get BitMEX Data Feed Source: https://docs.tardis.dev/api/http-api-reference Retrieves a data feed for BitMEX. Specify the 'from' parameter for the start timestamp and 'offset' for pagination. ```http https://api.tardis.dev/v1/data-feeds/bitmex?from=2019-04-01&offset=2 ``` -------------------------------- ### Connect to WebSocket for Normalized Replay (Python) Source: https://docs.tardis.dev/tardis-machine/replaying-historical-data Connects to the WebSocket endpoint to replay normalized historical market data. Ensure aiohttp is installed for this example. ```python import asyncio import aiohttp import json import urllib.parse async def main(): replay_options = { "exchange": "binance", "from": "2024-03-01", "to": "2024-03-02", "symbols": ["btcusdt"], "withDisconnectMessages": True, # other available data types examples: # 'book_snapshot_10_100ms', 'derivative_ticker', 'quote', # 'trade_bar_10ms', 'trade_bar_10s' "dataTypes": ["trade", "book_change", "book_snapshot_10_100ms"], } options = urllib.parse.quote_plus(json.dumps(replay_options)) URL = f"ws://localhost:8001/ws-replay-normalized?options={options}" async with aiohttp.ClientSession() as session: async with session.ws_connect(URL) as websocket: async for msg in websocket: print(msg.data) asyncio.run(main()) ``` -------------------------------- ### Connect to WebSocket for Normalized Replay (Node.js) Source: https://docs.tardis.dev/tardis-machine/replaying-historical-data Connects to the WebSocket endpoint to replay normalized historical market data. Ensure the 'ws' package is installed for this example. ```javascript import WebSocket from 'ws' const serialize = options => { return encodeURIComponent(JSON.stringify(options)) } const replayOptions = { exchange: 'binance', from: '2024-03-01', to: '2024-03-02', symbols: ['btcusdt'], withDisconnectMessages: true, // other available data types examples: // 'book_snapshot_10_100ms', 'derivative_ticker', 'quote', // 'trade_bar_10ms', 'trade_bar_10s' dataTypes: ['trade', 'book_change', 'book_snapshot_10_100ms'] } const options = serialize(replayOptions) const URL = `ws://localhost:8001/ws-replay-normalized?options=${options}` const ws = new WebSocket(URL) ws.onmessage = message => { console.log(message.data) } ``` -------------------------------- ### Python Client Example Source: https://docs.tardis.dev/historical-data-details/mango Example of how to fetch historical Mango Markets DEX data using the Python client library. This code retrieves L2 snapshot data for BTC-PERP between specified dates. ```APIDOC ## Fetch Mango Markets DEX Historical Data (Python) ### Description This snippet demonstrates how to use the `tardis-dev` Python library to retrieve historical market data from Mango Markets DEX. It fetches L2 snapshot data for a specified symbol within a given date range. ### Method ```python # pip install tardis-dev import asyncio from tardis_dev import Channel, replay async def main(): async for local_timestamp, message in replay( exchange="mango", from_date="2022-02-01", to_date="2022-02-02", filters=[Channel(name="l2snapshot", symbols=["BTC-PERP"])], api_key="YOUR_API_KEY", ): # messages as provided by Mango Markets DEX real-time stream print(message) asyncio.run(main()) ``` ### Parameters - `exchange` (string): The name of the exchange, 'mango' in this case. - `from_date` (string): The start date for the historical data retrieval (YYYY-MM-DD). - `to_date` (string): The end date for the historical data retrieval (YYYY-MM-DD). - `filters` (list): A list of Channel objects specifying the data types and symbols to retrieve. Example: `[Channel(name="l2snapshot", symbols=["BTC-PERP"])]`. - `api_key` (string): Your Tardis API key. ### Response The function yields `local_timestamp` and `message` for each data point retrieved. The `message` format is the same as provided by the real-time Mango Markets DEX WebSocket API. ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/bitfinex-derivatives Example of how to use the Node.js client library to fetch historical Bitfinex derivative data. ```APIDOC ## Node.js Client ### Description Use the `tardis-dev` Node.js library to replay historical market data. ### Method `replay` function ### Parameters - `exchange` (string) - Required - The exchange name, e.g., "bitfinex-derivatives". - `from` (string) - Required - The start date for the data retrieval (YYYY-MM-DD). - `to` (string) - Optional - The end date for the data retrieval (YYYY-MM-DD). - `filters` (array of objects) - Required - Specifies the data channels and symbols to subscribe to. Example: `[{ channel: 'book', symbols: ['BTCF0:USTF0'] }]`. - `apiKey` (string) - Required - Your Tardis API key. ### Response An async iterable yielding objects with `localTimestamp` and `message`. ### Request Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'bitfinex-derivatives', from: '2023-03-01', to: '2023-03-02', filters: [{ channel: 'book', symbols: ['BTCF0:USTF0'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by Bitfinex real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ``` -------------------------------- ### HTTP API Request Source: https://docs.tardis.dev/historical-data-details/bitflyer Fetch historical data directly via the HTTP API. This example requests 'lightning_board' data for FX_BTC_JPY starting from a specific date. ```APIDOC ## HTTP API Request ### Description Fetch historical data directly via the HTTP API. This example requests 'lightning_board' data for FX_BTC_JPY starting from a specific date. ### Method GET ### Endpoint `/v1/data-feeds/bitflyer` ### Query Parameters - `from` (string): The start date for historical data (YYYY-MM-DD). - `filters` (string): JSON string representing the data channels and symbols to retrieve. - `"[{"channel":"lightning_board","symbols":["FX_BTC_JPY"]}]"` - `offset` (integer): Offset for pagination, defaults to 0. ### Request Example ```bash curl --compressed -g 'https://api.tardis.dev/v1/data-feeds/bitflyer?from=2023-03-01&filters=[{"channel":"lightning_board","symbols":["FX_BTC_JPY"]}]&offset=0' ``` ### Response - The response contains historical data in the format provided by bitFlyer's real-time stream. ``` -------------------------------- ### Node.js Client for Historical Data Source: https://docs.tardis.dev/historical-data-details/coinbase-international Utilize the tardis-dev Node.js client to retrieve historical market data from Coinbase International. This example shows how to get LEVEL2 order book data for BTC-PERP. ```APIDOC ## Node.js Client for Historical Data ### Description Utilize the tardis-dev Node.js client to retrieve historical market data from Coinbase International. This example shows how to get LEVEL2 order book data for BTC-PERP. ### Method `replay` function from the `tardis-dev` library ### Parameters - **exchange** (string) - Required - The exchange name, e.g., "coinbase-international". - **from** (string) - Required - The start date for historical data (YYYY-MM-DD). - **to** (string) - Required - The end date for historical data (YYYY-MM-DD). - **filters** (array of objects) - Required - Specifies the channels and symbols to retrieve. Example: `[{ channel: 'LEVEL2', symbols: ['BTC-PERP'] }]`. - **apiKey** (string) - Required - Your Tardis API key. ### Request Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'coinbase-international', from: '2024-11-01', to: '2024-11-02', filters: [{ channel: 'LEVEL2', symbols: ['BTC-PERP'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by Coinbase International real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ### Response - **localTimestamp** (number) - The local timestamp of the message. - **message** (object) - The historical market data message as provided by the Coinbase International real-time stream. ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/bybit Example of how to use the Node.js client library to replay historical data from Bybit Derivatives. ```APIDOC ## Node.js Client Example ### Description This snippet shows how to retrieve historical Bybit Derivatives data using the Node.js client library. It covers setting the exchange, date range, filters, and processing the data stream. ### Method `replay` function from `tardis-dev` package ### Parameters - **exchange** (string) - Required - The name of the exchange (e.g., "bybit"). - **from** (string) - Required - The start date for data retrieval (YYYY-MM-DD). - **to** (string) - Required - The end date for data retrieval (YYYY-MM-DD). - **filters** (array of objects) - Required - An array defining the data channels and symbols. - **channel** (string) - The name of the data channel (e.g., "orderbook.50"). - **symbols** (array of strings) - The trading symbols to fetch data for (e.g., ["BTCUSD"]). - **apiKey** (string) - Required - Your Tardis API key. ### Response - **localTimestamp** (number) - The timestamp of the message. - **message** (object) - The historical data message, matching the Bybit Derivatives real-time stream format. ### Request Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'bybit', from: '2024-01-01', to: '2024-01-02', filters: [{ channel: 'orderbook.50', symbols: ['BTCUSD'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by Bybit Derivatives real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ``` -------------------------------- ### HTTP API for Historical Data Source: https://docs.tardis.dev/historical-data-details/huobi-dm Access HTX Coin-M Futures historical data directly via the HTTP API. This example demonstrates fetching 'depth' data for BTC_CW starting from 2024-01-01. ```APIDOC ## GET /v1/data-feeds/{exchange} ### Description Retrieves historical market data for a specified exchange. ### Method GET ### Endpoint `/v1/data-feeds/huobi-dm` ### Query Parameters - **from** (string) - Required - The start date for the data retrieval (YYYY-MM-DD). - **filters** (stringified JSON array) - Required - Specifies the channels and symbols to subscribe to. Example: `[{"channel":"depth","symbols":["BTC_CW"]}]`. - **offset** (integer) - Optional - Offset for pagination. ### Request Example ```bash curl --compressed -g 'https://api.tardis.dev/v1/data-feeds/huobi-dm?from=2024-01-01&filters=[{"channel":"depth","symbols":["BTC_CW"]}]&offset=0' ``` ``` -------------------------------- ### Node.js Client Example Source: https://docs.tardis.dev/historical-data-details/okex-swap Fetch OKX Swap historical data using the Node.js client library. This example demonstrates retrieving 'books-l2-tbt' data. ```APIDOC ## Node.js Client Example ### Description Fetch OKX Swap historical data using the Node.js client library. This example demonstrates retrieving 'books-l2-tbt' data. ### Method `replay` function from `tardis-dev` library ### Parameters - `exchange` (string): 'okex-swap' - `from` (string): Start date for data retrieval (e.g., '2024-01-01') - `to` (string): End date for data retrieval (e.g., '2024-01-02') - `filters` (array of objects): Specifies the data channels and symbols (e.g., `[{ channel: 'books-l2-tbt', symbols: ['BTC-USD-SWAP'] }]`) - `apiKey` (string): Your Tardis API key ### Request Example ```javascript // npm install tardis-dev import { replay } from 'tardis-dev'; const messages = replay({ exchange: 'okex-swap', from: '2024-01-01', to: '2024-01-02', filters: [{ channel: 'books-l2-tbt', symbols: ['BTC-USD-SWAP'] }], apiKey: 'YOUR_API_KEY' }); // messages as provided by OKX real-time stream for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message); } ``` ### Response - `localTimestamp` (number): Local timestamp of the message. - `message` (object): The historical data message as provided by the OKX real-time stream. ``` -------------------------------- ### Stream Real-time Spread Across Multiple Exchanges Source: https://docs.tardis.dev/node-client/normalization Stream real-time book changes from multiple exchanges and compute the spread. This example uses `streamNormalized` to get live data and `computeBookSnapshots` to calculate real-time quotes. ```javascript import { streamNormalized, normalizeBookChanges, combine, compute, computeBookSnapshots } from 'tardis-dev' const exchangesToStream = [ { exchange: 'binance', symbols: ['btcusdt'] }, { exchange: 'binance-futures', symbols: ['BTCUSDT'] }, { exchange: 'bybit', symbols: ['BTCUSDT'] } ] // for each specified exchange call streamNormalized for it // so we have multiple real-time streams for all specified exchanges const realTimeStreams = exchangesToStream.map(e => { return streamNormalized(e, normalizeBookChanges) }) // combine all real-time message streams into one const messages = combine(...realTimeStreams) // create book snapshots with depth1 that are produced // every time best bid/ask info is changed // effectively computing real-time quotes const realTimeQuoteComputable = computeBookSnapshots({ depth: 1, interval: 0, name: 'realtime_quote' }) // compute real-time quotes for combines real-time messages const messagesWithQuotes = compute(messages, realTimeQuoteComputable) const spreads = {} // print spreads info every 100ms setInterval(() => { console.clear() console.log(spreads) }, 100) // update spreads info real-time for await (const message of messagesWithQuotes) { if (message.type === 'book_snapshot') { spreads[message.exchange] = { spread: message.asks[0].price - message.bids[0].price, bestBid: message.bids[0], bestAsk: message.asks[0] } } } ``` -------------------------------- ### Stream Real-Time Market Data Source: https://docs.tardis.dev/node-client/streaming-real-time-data Use the `stream` function to connect to an exchange and receive real-time market data. This example streams trade and depth data for BTC/USDT from Binance. Ensure you have the 'tardis-dev' package installed. ```javascript import { stream } from 'tardis-dev' const messages = stream({ exchange: 'binance', filters: [ { channel: 'trade', symbols: ['btcusdt'] }, { channel: 'depth', symbols: ['btcusdt'] } ] }) for await (const { localTimestamp, message } of messages) { console.log(localTimestamp, message) } ```