Skip to main content

Binance API Data Exporter

This Python script allows you to retrieve historical data from Binance API and export it to a JSON file. The data can be retrieved for any specified symbol (e.g. BTCUSDT) and interval (e.g. 1m, 1h, 1d) for a given period of time.

Installation

  1. Install it via pip by running the following command in your terminal:
pip install binance-data-exporter
  1. Check out the project on PyPI at https://pypi.org/project/binance-data-exporter/.

  2. Clone the project repository from GitHub by running the following command in your terminal:

git clone git@github.com:zestones/Binance-Data-Exporter.git

Usage

To run the script, use the following command:

python binance_data_exporter.py [OPTIONS]

Bellow the list of available options you can use to customize the request to the Binance API:

Option Description Possible Values Default Value
-h,
--help
Show the help message and exit
-i,
--interval
The interval of the data 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M 1d
-p,
--pair
The pair of coin (refer to the binance symbol list) BTCUSDT, ETHUSDT, etc BTCUSDT
-l,
--limit
The limit of the data per request 1, 2, ..., 1000 (Should be integer) 500
-s,
--start-time
The start time of the data YYYY_MM_DD None
-e,
--end-time
The end time of the data YYYY_MM_DD TODAY
-o,
--output-folder
The folder where the data will be exported Path ./data

NOTE

  • If you don't specify a start time for your request, it will use the earliest available data for the requested time interval.
  • If the end-time is not specified the date of the day will be choosed by default.
  • If you dont provide parameters, the script will use the default values specified.

Examples

To retrieve data for ETHUSDT from 2018-01-15 to 2018-01-16 with an interval of 1 hour, a limit of 10, and export the data to ./data/eth_usdt/, use the following command:

python binance_data_exporter.py -l 10 -i 1h -p ETHUSDT -s 2018_01_15 -e 2018_01_16 -o ./data/eth_usdt/

You can customize the parameters to retrieve data as you wish.

Dependencies

The script requires the following dependencies:

  • requests
  • colorama
  • tabulate

You can install the dependencies using the following command:

pip install -r requirements.txt

Output

The script exports the retrieved data as a JSON file in the OUTPUT_FOLDER specified in the configuration. The filename of the JSON file is in the following format: symbol_start-date_to_end-date_interval.json

where start_date and end_date are the start and end dates of the data retrieved, respectively and interval is the interval between each data point.

API Limits and Maximum Number of Requests

Please note that Binance API has certain limits on the number of requests that can be made within a specific time frame.

It is important to be mindful of these limits when making requests to avoid being disconnected or banned. Make sure to not exceed the number of requests allowed by the API, when configuring the limit and interval parameters in the script.

Binance API Documentation

For more information on the Binance API, you can refer to the official documentation at:

https://binance-docs.github.io/apidocs/spot/en/

Metadata

Release files for binance-data-exporter 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for binance-data-exporter 0.2.7
File Size Uploaded
binance_data_exporter-0.2.7.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for binance-data-exporter 0.2.7
File Interpreter ABI Platform
binance_data_exporter-0.2.7-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / binance_data_exporter-0.2.7.tar.gz

Download URL binance_data_exporter-0.2.7.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
82f35a4594ac0723d20a598bac441937f6d79acc6e1c98582d8649498e504ccd
BLAKE2b-256 checksum
How to use checksums
8b5c7bd52093da7f2e0daabd20e34022f936190115a641745a49c75ffb4a091f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / binance_data_exporter-0.2.7-py3-none-any.whl

Download URL binance_data_exporter-0.2.7-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1df23c79b1eb69c1ff3f8e7e6c5ced054c143fa61eb1ade17b96a594a6cd4ec3
BLAKE2b-256 checksum
How to use checksums
4c2aae241b00992a398205676fe6a2823f4af2ef3e1340831c49a17c38025e66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.2.7 This release

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.1.9

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page