---
name: binance-ingestion
description: "How to get Binance API data into a pandas DataFrame in memory (the provider's terms limit storage or leave it unclear): access, the request, the format, limits, quirks and terms."
---

# Analyze Binance spot klines in memory

Source entry: https://signal-lab-jet.vercel.app/datasets/binance
Provider: https://www.binance.com/en/binance-api
Checked against the provider's documentation: 2026-10-29

## Access
- No account or API key for public market-data endpoints.
- Access varies by location. Binance states that its services may be restricted or blocked in some countries, and the global API refuses US locations with HTTP 451 (see the catalog entry). U.S. users should use Binance.US and its own API documentation. Observed 2026-10-29: api.binance.com returned HTTP 200 from our test environment.

## Request
```bash
curl 'https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1d&limit=5'
```

## Format
JSON array of 12-item arrays: open time, OHLC, volume, close time, quote volume, trade count, taker-buy base and quote volume, then an unused field. Prices and volumes arrive as strings; timestamps are Unix milliseconds.

## Load into pandas (in memory)
Needs Python 3 with requests and pandas. The provider's terms limit storage or leave it unclear, so this snippet does not write a file.
```python
"""Binance spot daily klines -> pandas in memory. The data is not persisted."""
import requests
import pandas as pd

URL = "https://api.binance.com/api/v3/klines"
params = {"symbol": "BTCUSDT", "interval": "1d", "limit": 5}
r = requests.get(URL, params=params, timeout=30)
r.raise_for_status()
columns = ["open_time", "open", "high", "low", "close", "volume", "close_time",
           "quote_volume", "trades", "taker_buy_volume", "taker_buy_quote_volume", "ignore"]
df = pd.DataFrame(r.json(), columns=columns)
df["open_time"] = pd.to_datetime(df["open_time"], unit="ms", utc=True)
df["close_time"] = pd.to_datetime(df["close_time"], unit="ms", utc=True)
for column in ("open", "high", "low", "close", "volume", "quote_volume",
               "taker_buy_volume", "taker_buy_quote_volume"):
    df[column] = pd.to_numeric(df[column])
print(len(df), "rows", df["open_time"].min().date(), "to", df["open_time"].max().date(),
      "; last close", df["close"].iloc[-1])
del df  # this example keeps no Binance market data after the process ends
```
Run by us on 2026-10-29 (python 3.13.5 | pandas 3.1.0 | pyarrow 26.0.0 | requests 2.34.2). Result: 5 rows 2026-10-26 to 2026-10-30 ; last close 77078.56

## Limits
- The current exchangeInfo response states 6,000 REQUEST_WEIGHT per minute. Limits are per IP, and each klines request has weight 2.
- Klines default to 500 rows and allow at most 1,000 rows per request.

## Quirks
- The snippet intentionally writes no file because the terms pages checked do not state permission to store or redistribute market data.
- The newest daily candle can still be open; close_time identifies when it is scheduled to finish.
- Access varies by location. Do not bypass a location block. Observed 2026-10-29 from our test environment: the global endpoint and the same request to api.binance.us both returned HTTP 200.

## Terms and attribution
- Binance states that its services may be wholly or partly restricted in some countries and that access may be blocked. Do not circumvent the restriction.
- The terms grant use of Binance intellectual property, excluding trademarks, only as needed to receive the services for non-commercial personal or internal business use.
- The terms list Binance APIs as one way to access a Binance Account, subject to separate API terms and Binance's approval. The pages checked do not state permission to persist, redistribute or commercially publish market data, so this snippet keeps the response only in memory.
- Terms page: https://www.binance.com/en/terms

## Sources
- https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md: "If unspecified, the security type is `NONE`."
- https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md: "Public market data"
- https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md: "limit | INT | NO | Default: 500; Maximum: 1000."
- https://api.binance.com/api/v3/exchangeInfo?symbol=BTCUSDT: ""rateLimitType":"REQUEST_WEIGHT","interval":"MINUTE","intervalNum":1,"limit":6000"
- https://docs.binance.us/: "GET /api/v3/klines Use this endpoint to get Kline/candlestick bars for a token symbol. Klines are uniquely identified by their open time. Please note the maximum limit is 1,000 bars."
- https://bin.bnbstatic.com/static/cms/cg08ou2ak0tn7mcplvfg/file/f7c3c8a8fbda48eaa272ff503b8c2e54c6c98ad4f0f2a1e5da3667af5962c7de.pdf: "Binance Services may be wholly or partially restricted in some countries"
- https://bin.bnbstatic.com/static/cms/cg08ou2ak0tn7mcplvfg/file/f7c3c8a8fbda48eaa272ff503b8c2e54c6c98ad4f0f2a1e5da3667af5962c7de.pdf: "excluding the Trade Marks, solely as necessary to allow you to receive the Binance Services for non-commercial personal or internal business use"
- https://bin.bnbstatic.com/static/cms/cg08ou2ak0tn7mcplvfg/file/f7c3c8a8fbda48eaa272ff503b8c2e54c6c98ad4f0f2a1e5da3667af5962c7de.pdf: "Binance APIs, subject to separate API terms and our approval"

Information for educational purposes only. Free tiers, limits and licenses belong to the providers and may change; check the provider's own terms before using the data.
