binance-vision
Download historical cryptocurrency market data from Binance Vision — spot, USD-M futures, COIN-M futures and options — straight into a pandas DataFrame.
Binance publishes its historical data as thousands of individual zipped CSVs, split by market, data type, symbol, interval and calendar period, with inconsistent headers and timestamp units. This package hides all of that behind a single function.
from binance_vision import fetch_data
result = fetch_data(
ticker="BTCUSDT",
start_date="2024-01-01",
end_date="2024-03-15",
market="spot",
data_type="klines",
interval="1h",
)
print(result)
# FetchResult(rows=1800, files_used=17, missing=0, failed=0, output_path=None)
print(result.data.head())
Install
pip install binance-vision
Requires Python 3.9+.
Why not just download the files yourself
| Problem | What this package does |
|---|---|
| Data is split into monthly and daily archives | Plans the range automatically — whole calendar months use the monthly archive, the partial edges fall back to daily files |
| Some CSVs have a header row, some don't | Sniffs each file individually and applies the correct column names |
| Epoch columns switched from ms to µs mid-2025 for some feeds | Infers the unit per file from the magnitude and converts to UTC datetimes |
Every archive has a .CHECKSUM sidecar |
Verifies SHA-256 on every download, failing loudly on corruption |
| Hundreds of files for a long range | Downloads concurrently with a configurable worker pool |
| Some periods were never published | Reported in result.missing — a partial range never raises |
Usage
The result object
fetch_data() returns a FetchResult:
| Attribute | Description |
|---|---|
data |
The concatenated pandas.DataFrame, sorted by its primary time column |
output_path |
Path written to, or None if output_path was not given |
files_used |
Period labels successfully downloaded and parsed ("2024-01", "2024-01-15") |
missing |
Period labels with no file published upstream — not an error |
failed |
(label, error) pairs for real failures: network, checksum or parse errors |
Writing to disk
result = fetch_data(
"ETHUSDT", "2024-01-01", "2024-01-31",
market="usdm", data_type="klines", interval="5m",
output_format="parquet", # or "csv"
output_path="data/eth_5m", # extension added automatically
)
print(result.output_path) # data/eth_5m.parquet
Discovering what's available
from binance_vision import supported_markets, supported_data_types
supported_markets()
# ('spot', 'usdm', 'coinm', 'options')
supported_data_types("usdm")
# ('aggTrades', 'bookDepth', 'bookTicker', 'indexPriceKlines', 'klines',
# 'liquidationSnapshot', 'markPriceKlines', 'metrics', 'premiumIndexKlines', 'trades')
Checking for gaps
A range that is only partly published still returns everything it could get:
result = fetch_data("BTCUSDT", "2025-05-25", "2025-06-05",
market="usdm", data_type="bookTicker")
if result.missing:
print(f"No data published for: {result.missing}")
if result.failed:
raise RuntimeError(f"Downloads failed: {result.failed}")
API
fetch_data(
ticker: str,
start_date: str | date | datetime,
end_date: str | date | datetime,
market: str,
data_type: str,
interval: str | None = None,
output_format: str = "parquet",
output_path: str | None = None,
max_workers: int = 8,
) -> FetchResult
| Parameter | Description |
|---|---|
ticker |
Symbol as published by Binance, e.g. "BTCUSDT", "BTCUSD_PERP". Case-insensitive |
start_date, end_date |
Inclusive UTC date range. "YYYY-MM-DD" string, date or datetime |
market |
"spot", "usdm", "coinm" or "options" (aliases: um, cm, usd-m, coin-m, option) |
data_type |
See the table below. Invalid combinations raise ValueError listing the valid types |
interval |
Required for the klines family, e.g. "1m", "1h", "1d" |
output_format |
"parquet" (default) or "csv". Only used when output_path is set |
output_path |
If given, the DataFrame is also written here |
max_workers |
Concurrent downloads (default 8) |
Supported data types
| Market | Data type | Granularity | Needs interval |
|---|---|---|---|
| spot | klines |
monthly + daily | yes |
| spot | trades, aggTrades |
monthly + daily | no |
| usdm / coinm | klines, indexPriceKlines, markPriceKlines, premiumIndexKlines |
monthly + daily | yes |
| usdm / coinm | trades, aggTrades, bookTicker |
monthly + daily | no |
| usdm / coinm | bookDepth, metrics, liquidationSnapshot |
daily only | no |
| options | BVOLIndex, EOHSummary, trades |
daily only | no |
Retired feeds. Binance has stopped publishing futures
liquidationSnapshot(the bucket prefix is now empty for every symbol) and optionEOHSummary(last file2023-10-23). They remain in the registry so existing scripts keep working; requesting them returns the periods inresult.missing.
Notes
- All timestamp columns are converted to timezone-aware UTC datetimes.
- Trade-level data types are large — a single day of
spot/tradesfor a major pair is well over a million rows. Preferparquetoutput and narrow ranges. - Binance Vision is a free, unauthenticated static file host. No API key is
needed, but please be considerate with
max_workers.
Development
git clone https://github.com/Njenjo/binance-vision
cd binance-vision
pip install -e ".[dev]"
Run the offline unit tests:
pytest -m "not network"
Run the full suite, including live requests against data.binance.vision:
pytest
License
MIT — see LICENSE.
Disclaimer
This project is not affiliated with, endorsed by, or connected to Binance. It is an independent client for their public historical data archive. Market data is provided as-is; verify it before relying on it for trading decisions.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file binance_vision-0.1.0.tar.gz.
File metadata
- Download URL: binance_vision-0.1.0.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ceb2d379dd3eceefb9b978bbf69c165f6eeee173a38be2082d56dcab04b0659
|
|
| MD5 |
2af0e074a40cc97e52ef88f1ae636f24
|
|
| BLAKE2b-256 |
683a3fdf17538d6f2996a3b9ee9d0318c46689ee85b92162f181689f17e92331
|
File details
Details for the file binance_vision-0.1.0-py3-none-any.whl.
File metadata
- Download URL: binance_vision-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec9554a9f1cb49412f4459a641ced567c2af017501fc342bbdd111fc985724a8
|
|
| MD5 |
56a8254d45208193a3600743940e53ae
|
|
| BLAKE2b-256 |
c642a9ab8936b3ad1728f918f03a8c31ffa58f10c056a2ececc2ca78cd0bf0d2
|