{"id":8699,"library":"tardis-client","title":"Tardis.dev Python Client","description":"The `tardis-client` library provides a Python interface for accessing historical tick-level cryptocurrency market data from tardis.dev. It facilitates replaying historical data via an asynchronous generator and offers local file-based caching. The current version is 1.4.2. **Note: This package is deprecated and has been replaced by the `tardis-dev` package, where all new development is focused.**","status":"deprecated","version":"1.4.2","language":"en","source_language":"en","source_url":"https://github.com/tardis-dev/python-client","tags":["cryptocurrency","market data","API client","historical data","async","tick data","deprecated"],"install":[{"cmd":"pip install tardis-client","lang":"bash","label":"Install `tardis-client` (deprecated)"},{"cmd":"pip install tardis-dev","lang":"bash","label":"Install `tardis-dev` (recommended replacement)"}],"dependencies":[],"imports":[{"note":"TardisClient is specific to the deprecated 'tardis-client' package. The replacement 'tardis-dev' uses a top-level `replay` function instead.","wrong":"from tardis_dev import TardisClient","symbol":"TardisClient","correct":"from tardis_client import TardisClient"},{"note":"While 'Channel' exists in both, its usage pattern and containing package for replay functions differ in the new 'tardis-dev' package. For 'tardis-dev', 'Channel' is imported directly from 'tardis_dev'.","wrong":"from tardis_dev.client import Channel","symbol":"Channel","correct":"from tardis_client import Channel"}],"quickstart":{"code":"import asyncio\nimport os\nfrom tardis_client import TardisClient, Channel\n\nasync def replay_data():\n    api_key = os.environ.get('TARDIS_API_KEY', '')\n    \n    # Note: For full historical access, an API key is required.\n    # Without an API key, only the first day of each month is accessible.\n    # The cache_dir is optional; default is os.tmpdir/.tardis-cache.\n    tardis_client = TardisClient(api_key=api_key, cache_dir=\"./tardis_cache\")\n\n    print(\"Replaying BitMEX trades and order book for 2019-06-01...\")\n    messages = tardis_client.replay(\n        exchange=\"bitmex\",\n        from_date=\"2019-06-01\",\n        to_date=\"2019-06-02\", # Non-inclusive end date\n        filters=[\n            Channel(name=\"trade\", symbols=[\"XBTUSD\", \"ETHUSD\"]),\n            Channel(\"orderBookL2\", [\"XBTUSD\"])\n        ],\n    )\n\n    message_count = 0\n    async for local_timestamp, message in messages:\n        # local_timestamp is a Python datetime object\n        # message is the raw message object from the exchange real-time stream\n        if message_count < 5: # Print first 5 messages as an example\n            print(f\"[{local_timestamp}] {message['symbol']}: {message['data_type']}\")\n        message_count += 1\n        \n    print(f\"\\nFinished replaying. Total messages received: {message_count}\")\n    # Optionally clear the cache\n    # tardis_client.clear_cache()\n\nif __name__ == \"__main__\":\n    # Set your API key as an environment variable or pass it directly\n    # os.environ['TARDIS_API_KEY'] = 'YOUR_TARDIS_API_KEY'\n    asyncio.run(replay_data())\n","lang":"python","description":"This quickstart demonstrates how to use the deprecated `tardis-client` to replay historical market data for BitMEX. It fetches trades for 'XBTUSD' and 'ETHUSD', and Level 2 order book data for 'XBTUSD' for a specific date range. An API key is typically required for full access to historical data."},"warnings":[{"fix":"Uninstall `tardis-client` (`pip uninstall tardis-client`) and install the new client (`pip install tardis-dev`). Update your import statements and usage patterns according to the migration guide: `https://docs.tardis.dev/python-client/migration-notice`.","message":"The `tardis-client` package is deprecated and frozen. No new features will be added, and future Python development continues under the `tardis-dev` package. Existing users should migrate.","severity":"breaking","affected_versions":"All versions of `tardis-client` (1.x.x)"},{"fix":"Obtain an API key from Tardis.dev and pass it to the `TardisClient` constructor (or set the `TARDIS_API_KEY` environment variable). For `tardis-dev`, pass it directly to `replay()` or `download_datasets()`.","message":"Access to full historical data requires a Tardis.dev API key. Without one, only the first day of each month is accessible.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure all I/O operations (especially file writes during data processing) are non-blocking or use asynchronous libraries (e.g., `aiofiles`) to avoid blocking the event loop. Clear the local `.tardis-cache` if issues persist.","message":"Performing blocking I/O operations (e.g., synchronous file writes) within the `asyncio` event loop used by `tardis-client` can cause `ConnectionResetError` or `EOFError` due to the event loop being blocked, leading to network connection timeouts.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Regularly clear the cache using `tardis_client.clear_cache()` or configure a specific `cache_dir` that can be managed manually. The newer `tardis-machine` (Node.js component, not this Python client) offers `autoCleanup: true` for clearing cache after replay.","message":"The local file cache (`<os.tmpdir>/.tardis-cache` by default) can grow significantly, consuming disk space, especially during large historical data backfills.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Replace blocking file operations with their asynchronous equivalents (e.g., using `aiofiles`) or ensure I/O is offloaded to a separate thread/process to keep the `asyncio` event loop responsive. Clear the `.tardis-cache` directory.","cause":"These errors often occur when the Python `asyncio` event loop is blocked by synchronous (blocking) I/O operations, such as writing to files, preventing the network connection from being properly maintained.","error":"ConnectionResetError: [Errno 54] Connection reset by peer OR EOFError: Read up to 0 bytes from peer"},{"fix":"Ensure you have a valid Tardis.dev API key. Pass it correctly to the `TardisClient` constructor using the `api_key` argument, or set it as the `TARDIS_API_KEY` environment variable. Verify the API key's permissions on the Tardis.dev website.","cause":"The API key provided is either missing, invalid, or does not have sufficient permissions for the requested data. For full historical data, an API key is always required.","error":"HTTP status 401 Unauthorized"}]}