Accessing accurate and comprehensive historical cryptocurrency data is essential for traders, developers, and analysts building strategies, backtesting models, or conducting market research. The binance_historical_data Python package simplifies this process by enabling users to download complete price and volume records directly from Binance servers β all with minimal code and no requirement for a Binance account.
Whether you're analyzing spot markets or futures trading activity, this lightweight yet powerful tool supports multiple asset classes and data types, delivering structured .csv files ready for immediate use in data analysis pipelines.
What Is binance_historical_data?
binance_historical_data is a Python library (compatible with Python 3.8+) designed to streamline the retrieval of historical crypto market data from Binance. It eliminates complex API handling by wrapping Binance's data endpoints into a clean, intuitive interface.
With just three lines of code, you can:
- Download full historical klines (candlestick data) for any supported trading pair
- Update existing datasets automatically
- Store data locally in organized folders
π Discover how easy it is to start analyzing real crypto market trends today.
Key Features
- No Binance API key required
- Supports spot, USD-margined futures (um), and coin-margined futures (cm)
- Multiple data types including klines, trades, and index prices
- Automatic date management and file organization
- Lightweight and dependency-minimal design
Installation
Getting started is straightforward using pip:
pip install binance_historical_dataEnsure your environment meets the minimum Python version requirement (3.8 or higher). Once installed, import the package and initialize the data dumper.
How to Use the Data Dumper
Initialize the Main Object
Start by creating an instance of BinanceDataDumper with your preferred configuration:
from binance_historical_data import BinanceDataDumper
data_dumper = BinanceDataDumper(
path_dir_where_to_dump=".",
asset_class="spot", # Options: spot, um, cm
data_type="klines", # e.g., aggTrades, klines, trades
data_frequency="1m" # e.g., 1m, 5m, 1h, 1d
)Configuration Parameters
path_dir_where_to_dump: Directory path where data will be savedasset_class: Market type β"spot"for regular trading,"um"for USD-margined futures,"cm"for coin-margineddata_type: Type of data to retrieve- For spot:
klines,trades,aggTrades - For futures: additional options like
markPriceKlines,indexPriceKlines, andmetrics(UM only)
- For spot:
data_frequency: Time interval for kline data (e.g.,"1m","1h","1d")
Downloading Historical Data
Core Method: dump_data()
The primary method to fetch data is simple and flexible:
data_dumper.dump_data(
tickers=None,
date_start=None,
date_end=None,
is_to_update_existing=False,
tickers_to_exclude=["UST"]
)Parameter Breakdown
tickers: List of trading pairs (e.g.,["BTCUSDT", "ETHUSDT"]). IfNone, defaults to all USDT pairs.date_start: Start date (datetime.date). IfNone, begins from the earliest available (typically 2017-01-01).date_end: End date. IfNone, defaults to today.is_to_update_existing: IfTrue, checks existing files and downloads only missing or new data.tickers_to_exclude: Exclude specific symbols (e.g., unstable or deprecated ones like"UST").
Example: Full Historical Dump
To download all kline data for every USDT trading pair since inception:
data_dumper.dump_data()β οΈ Note: The initial full download may take up to 40 minutes depending on your connection and system performance.
Example: Update Existing Dataset
To refresh your local dataset with newly available data:
data_dumper.dump_data(is_to_update_existing=True)This intelligent update avoids re-downloading existing files and only fetches new entries.
Example: Targeted Date Range Reload
Re-fetch data for a specific period to correct gaps or refresh corrupted files:
import datetime
data_dumper.dump_data(
date_start=datetime.date(2021, 1, 1),
date_end=datetime.date(2022, 1, 1),
is_to_update_existing=True
)π Start building your own crypto analytics engine now.
Managing Local Data Files
After downloading, data is stored as .zip archives and automatically unzipped into structured directories.
Delete Outdated Daily Files
Once monthly aggregates are downloaded, daily files become redundant. Clean them up efficiently:
data_dumper.delete_outdated_daily_results()This reduces storage usage without losing data integrity.
Kline Data Format (.csv Columns)
Each kline (candlestick) record contains the following fields:
- Open time β Timestamp (UTC)
- Open β Opening price
- High β Highest price during the interval
- Low β Lowest price during the interval
- Close β Closing price
- Volume β Base asset volume
- Close time β Timestamp (UTC)
- Quote asset volume
- Number of trades
- Taker buy base asset volume
- Taker buy quote asset volume
- Ignore β Placeholder field (can be disregarded)
This structure aligns with standard OHLCV formats used in financial analysis libraries like Pandas and TA-Lib.
Additional Utility Methods
Enhance your workflow with built-in helper functions.
Get All Available Trading Pairs
all_pairs = data_dumper.get_list_all_trading_pairs()
print(all_pairs)Returns a list of all active tickers on Binance matching the selected asset class.
Find Earliest Available Data Date
min_date = data_dumper.get_min_start_date_for_ticker("BTCUSDT")
print(min_date)Useful when setting up backtests or validating data availability.
List Locally Stored Tickers
saved_tickers = data_dumper.get_all_tickers_with_data(timeperiod_per_file="daily")
print(saved_tickers)Helps manage large datasets across different time granularities.
Retrieve Dates with Saved Data
dates = data_dumper.get_all_dates_with_data_for_ticker("ETHUSDT", "monthly")
print(dates)Ideal for auditing or incremental processing.
Access File Paths and Names
Determine where specific files are stored:
local_dir = data_dumper.get_local_dir_to_data("BTCUSDT", "monthly")
filename = data_dumper.create_filename("BTCUSDT", datetime.date.today(), "daily")Facilitates integration with external scripts or backup systems.
Frequently Asked Questions (FAQ)
Q: Do I need a Binance account or API key to use this package?
A: No. This tool accesses public Binance endpoints, so no registration or authentication is required.
Q: How frequently is new data available?
A: Daily updates appear on Binance servers shortly after 00:00 UTC. There may be a brief delay before theyβre accessible via the API.
Q: Can I download minute-level data for multiple years?
A: Yes. The package supports granular intervals (down to 1-minute) and long time ranges starting from 2017.
Q: Is futures market data supported?
A: Absolutely. You can download mark price klines, index prices, and metrics for both USD-margined (um) and coin-margined (cm) futures.
Q: What happens if my download gets interrupted?
A: Use is_to_update_existing=True to resume. The tool detects missing dates and completes the download seamlessly.
Q: How much disk space will I need?
A: A full USDT spot dataset at 1-minute resolution may require several gigabytes. Monthly aggregation helps reduce footprint significantly.
Final Thoughts
The binance_historical_data package empowers developers and analysts with frictionless access to high-quality crypto market history. Its simplicity, flexibility, and reliability make it ideal for research, strategy development, and long-term trend analysis.
Whether you're running quantitative models or visualizing price movements, having a complete local copy of Binance data puts you in full control of your analytical pipeline.
π Take the next step in mastering crypto market dynamics β explore advanced tools today.